Questions from Starting Out With Java


Q: What is the difference between private members and protected members?

What is the difference between private members and protected members?

See Answer

Q: Why should you avoid making class members protected when possible?

Why should you avoid making class members protected when possible?

See Answer

Q: What is the difference between private access and package access?

What is the difference between private access and package access?

See Answer

Q: Why is it easy to give package access to a class member

Why is it easy to give package access to a class member by accident?

See Answer

Q: Look at the following class definition: public class ClassD extends

Look at the following class definition: public class ClassD extends ClassB { (Member Declarations . . .) } Because ClassD inherits from ClassB, is it true that ClassD does not inherit from the Object...

See Answer

Q: When you create a class, it automatically has a toString method

When you create a class, it automatically has a toString method and an equals method. Why?

See Answer

Q: Recall the Rectangle and Cube classes discussed earlier, as shown in

Recall the Rectangle and Cube classes discussed earlier, as shown in Figure10-18. 1. Is the following statement legal or illegal? If it is illegal, why? Rectangle r = new Cube(10, 12, 5); 2. If you de...

See Answer

Q: Write a for loop that calculates the total of the following series

Write a for loop that calculates the total of the following series of numbers: 130+229+328+⋯301

See Answer

Q: What is the purpose of an abstract method?

What is the purpose of an abstract method?

See Answer

Q: Look at the following class declarations and answer the questions that follow

Look at the following class declarations and answer the questions that follow them: public class Shape { private double area; public void setArea(double a) { area = a; } public double getArea() { retu...

See Answer