Compare and contrast the private visibility modifier to the protected visibility modifier. Why is the protected visibility modifier a better choice in an inheritance hierarchy?

What will be an ideal response?


The private modifier and the protected modifier both enforce the encapsulation of instance variables
and methods in a class. This means that unrelated classes are not able to directly access the variables and the methods. The
protected modifier, however, does allow for the instance variables and the methods to be accessed by subclasses of the
original class. This makes the protected modifier a better choice for use in an inheritance hierarchy, because it is often
useful for subclasses to have access to a superclass's instance variables and methods.

Computer Science & Information Technology

You might also like to view...

Which company was well-known for a token ring technology?

What will be an ideal response?

Computer Science & Information Technology

________ view allows you to change the layout of the form by moving the controls and resizing or adding controls

Fill in the blank(s) with correct word

Computer Science & Information Technology

____ rows and columns lets you keep headings on the screen as you work with the data in a large worksheet.

A. Hiding B. Freezing C. Showing D. Sealing

Computer Science & Information Technology

____________________ Internet access comes in two varieties: one-way and two-way.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology