Questions from Starting Out With Java


Q: Class B extends class A. (Class A is the superclass

Class B extends class A. (Class A is the superclass and class B is the subclass.) Describe the order in which the class’s constructors execute when a class B object is created.

See Answer

Q: Look at the following classes: public class Ground {

Look at the following classes: public class Ground { public Ground() { System.out.println("You are on the ground."); } } public class Sky extends Ground { public Sky() { System.out.println("You are in...

See Answer

Q: Look at the following classes: public class Ground {

Look at the following classes: public class Ground { public Ground() { System.out.println("You are on the ground."); } public Ground(String groundColor) { System.out.println("The ground is " + ground...

See Answer

Q: Under what circumstances would a subclass need to override a superclass method

Under what circumstances would a subclass need to override a superclass method?

See Answer

Q: How can a subclass method call an overridden superclass method?

How can a subclass method call an overridden superclass method?

See Answer

Q: If a method in a subclass has the same signature as a

If a method in a subclass has the same signature as a method in the superclass, does the subclass method overload or override the superclass method?

See Answer

Q: If a method in a subclass has the same name as a

If a method in a subclass has the same name as a method in the superclass, but uses a different parameter list, does the subclass method overload or override the ­superclass method?

See Answer

Q: Briefly describe what an exception is.

Briefly describe what an exception is.

See Answer

Q: When does the code in a finally block execute?

When does the code in a finally block execute?

See Answer

Q: Convert the following while loop to a for loop: int

Convert the following while loop to a for loop: int count = 0; while (count < 50) { System.out.println("count is " + count) ; Count++ ; }

See Answer