Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Object Oriented Programming 6. Why are member variables usually declared Private

ID: 3710803 • Letter: O

Question

Object Oriented Programming

6. Why are member variables usually declared Private in classes? 


7. At the end of the following example, how many Student objects exist? 
Dim st1 As New Student 
Dim st2 As Student 
st2 = st1


8. At the end of the following example, how many Student objects exist? 
Dim st1 As New Student 
Dim st2 As Student 
st2 = st1 
st1 = Nothing


9. Suppose that an application at an animal hospital uses two classes: Mammaland Dog. Which do you think 
is the base class and which is the derived class? Why?


10. Why does it make sense that you cannot use the Overridable keyword in a private base class 
member declaration?

Explanation / Answer

Solution:

6)

Because this is a best programming practice to maintain the abstraction and encapsulation, it is good for security.

7)

Only one Student object will be created at the end

8)

Only one Student object will be created at the end

9)

The mammal class is the base class since dog is a mammal

10)

It is because private members are not visible in private class.

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)