Some programmers prefer not to use protected access, because they believe it breaks the encapsulation of the base class. Discuss the relative merits of using protected access vs. using private access in base classes.

What will be an ideal response?


private instance variables are hidden in the derived class and are accessible only
through the public or protected properties and methods of the base class. Using
protected access enables the derived class to manipulate the protected members
without using the properties and methods of the base class. If the base class instancae
variables are private, the properties of the base class must be used to access the data.
This may result in a decrease in performance due to the extra accessor and method
calls. Declaring private instance variables in a base class helps you test, debug and
correctly modify systems. If a derived class could access its base class’s private instance
variables, classes that inherit from that base class could access the instance variables
as well. This would propagate access to what should be private instance
variables, and the benefits of information hiding would be lost.

Computer Science & Information Technology

You might also like to view...

Some larger mobile phones display pages at screen widths of 600 pixels or more in ____ mode.

A. portrait B. normal C. page D. landscape

Computer Science & Information Technology

Which of the following is false regarding VRML?

a) It is a markup language. b) It is purely a text language. c) It is an extension of the Microsoft ActiveX controls. d) Its files have the extension ".wrl"

Computer Science & Information Technology

What best describes a criteria range?

A) The table upon which a filter is applied B) The copied range of cells C) The filtered range of cells D) The group of adjacent cells that specifies the conditions used to control the results of a filter

Computer Science & Information Technology

Windows Server 2012 R2 includes the ________ feature, which provides guaranteed message delivery, efficient routing, security, and priority-based messaging between applications, including those that run on different operating systems

Fill in the blank(s) with correct word

Computer Science & Information Technology