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 data members are hidden in the base class and are accessible only through
the public or protected member functions of the base class. Using protected access
enables the derived class to manipulate the protected members without using the access
functions of the base class. If the base-class members are private, the member
functions of the base class must be used to access the data. This may result in a decrease
in performance due to the extra function calls, yet accessing and modifying
private data in this indirect manner helps ensure that the data in the base class remains
consistent.
You might also like to view...
With a series of check boxes, only one box may be selected at a time.
Answer the following statement true (T) or false (F)
What is the output of the following program?
``` import java.util.Date; public class Test { public static void main(String[] args) { Date date = new Date(1234567); m1(date); System.out.print(date.getTime() + " "); m2(date); System.out.println(date.getTime()); } public static void m1(Date date) { date = new Date(7654321); } public static void m2(Date date) { date.setTime(7654321); } } ``` a. 1234567 1234567 b. 1234567 7654321 c. 7654321 1234567 d. 7654321 7654321
When you have a photograph or other printed image, you can use a(n) ____________________ to convert the image into a bitmap graphic.
Fill in the blank(s) with the appropriate word(s).
(World Population Growth) World population has grown considerably over the centuries. Continued growth could eventually challenge the limits of breathable air, drinkable water, arable cropland and other limited resources. There is evidence that growth has been slowing in recent years and that world population could peak some time this century, then start to decline. For this exercise, research world population growth issues online. Be sure to investigate various viewpoints. Get estimates for the current world population and its growth rate (the percentage by which it is likely to increase this year). Write a program that calculates world population growth each year for the next 75 years, using the simplifying assumption that the current growth rate will stay constant. Print the results in
What will be an ideal response?