Subjects
PRICING
COURSES
SIGN IN
Start Free Trial
Luyang D.
Experienced Computer Science Tutor
Tutor Satisfaction Guarantee
Python Programming
TutorMe
Question:

Consider the following code: list1 = [1,2,3,4,5] list2 = list1 list2[1] = 1 print(list1) print(list2) What will be the result? And why?

Luyang D.
Answer:

The result will be [1,1,3,4,5] [1,1,3,4,5] The reason is that the variable stands for a list is actually a value that points to the block of memory of the list. When list2=list1 gets executed, the "pointer" value get assigned to list2. Thus they stands for the same memory of the list. When we change the element in either list1 or list2, we are changing the same list. That's why the two print statement give the same result, [1,1,3,4,5].

Java Programming
TutorMe
Question:

What are the differences between abstract class and interface in Java?

Luyang D.
Answer:

As we know, both abstract class and interface in Java are used as blueprints to achieve abstraction. They look similar due to the fact that there are usually more declarations than implementation in both cases. For abstract class, it can have abstract and non-abstract methods, doesn't support multiple inheritance, can have final, non-final, static and non-static variables, can provide the implementation of interface. However, for the interface, it can have only abstract methods. Since Java 8, it can have default and static methods also. And it supports multiple inheritance, has only static and final variables.

C++ Programming
TutorMe
Question:

What do public, protected and privated inheritance do in C++ Inheritance?

Luyang D.
Answer:

In C++ public inheritance, the child class will inherite the members with the same accessor from the parent's. In the protected inheritance, the child class will inherite the public members in the parent class as protected members. The protected members will be kept the same way. At last, in the private inheritance, the child class will inherite the public and protected members in the parent class as private members. In all cases, the private members will always be kept inside its own class and cannot be access from outside the class.

Send a message explaining your
needs and Luyang will reply soon.
Contact Luyang
Ready now? Request a lesson.
Start Session
FAQs
What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Session" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.