Questions from Starting Out With Java


Q: Is it advisable or not advisable to write a method that returns

Is it advisable or not advisable to write a method that returns a reference to an object that is a private field? What is the exception to this?

See Answer

Q: Look at the following declaration: enum Color { RED,

Look at the following declaration: enum Color { RED, ORANGE, GREEN, BLUE} 1. What is the name of the data type declared by this statement? 2. What are the enum constants for this type? 3. Write a stat...

See Answer

Q: Why should you use StringBuilder objects instead of String objects in a

Why should you use StringBuilder objects instead of String objects in a program that makes lots of changes to strings?

See Answer

Q: Each of the numeric wrapper classes has a static toString method.

Each of the numeric wrapper classes has a static toString method. What do these methods do?

See Answer

Q: What is an “is-a†relationship?

What is an “is-a†relationship?

See Answer

Q: What is an abstract class?

What is an abstract class?

See Answer

Q: When you instantiate an anonymous inner class, the class must do

When you instantiate an anonymous inner class, the class must do one of two things. What are they?

See Answer

Q: What is a lambda expression?

What is a lambda expression?

See Answer

Q: What is the superclass and what is the subclass in the following

What is the superclass and what is the subclass in the following line? public class Pet extends Dog

See Answer

Q: Can a subclass ever directly access the private members of its superclass

Can a subclass ever directly access the private members of its superclass?

See Answer