Filters
Question type

Study Flashcards

A method in a subclass overriding a method in a superclass cannot call the superclass method.

A) True
B) False

Correct Answer

verifed

verified

Several classes implement an interface, but all of them implement the same method using the same code. To provide a common method for all of these classes, you would create an abstract class.

A) True
B) False

Correct Answer

verifed

verified

The extends keyword specifies that the subclass inherits members of the superclass, so:


A) the base class begins with a set of predefined methods and fields inherited from its hierarchy of superclasses.
B) the derived class begins with a set of predefined methods and fields inherited from its hierarchy of superclasses.
C) the derived class begins with a set of predefined methods inherited from its hierarchy of fields.
D) the base class begins with a set of predefined methods inherited from its hierarchy of derived classes.

E) C) and D)
F) None of the above

Correct Answer

verifed

verified

An interface can contain one or more static constants.

A) True
B) False

Correct Answer

verifed

verified

Which of the following are not inherited by subclasses?


A) public fields and public methods
B) private fields and private methods
C) protected fields and protected methods
D) All of these are correct.

E) B) and C)
F) All of the above

Correct Answer

verifed

verified

Protected fields and methods are inherited.

A) True
B) False

Correct Answer

verifed

verified

Abstract methods can be overridden.

A) True
B) False

Correct Answer

verifed

verified

If the call to the direct superclass constructor was not the first statement in the constructor, a compiler error will be generated.

A) True
B) False

Correct Answer

verifed

verified

If a class has an abstract method, then that class must be declared abstract.

A) True
B) False

Correct Answer

verifed

verified

Which of the options listed will happen if the following code segment is run, assuming the remainder of the program is coded correctly? 10 public class Circle extends Figure 11 { 12 private int radius; 13 public Circle( ) 14 { 15 super( ) ; 16 radius = 0;


A) The default constructor of the Figure class will be called (line 15) .
B) The default constructor of Radius class will set radius to 0.
C) The attempt to instantiate an object of the abstract class will generate a compiler error.
D) All of these are correct.

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

Inheritance helps organize related classes into __________.

Correct Answer

verifed

verified

When class B inherits from class A:


A) A is the superclass and B is the subclass.
B) A is the subclass and B is the superclass.

C) A) and B)
D) undefined

Correct Answer

verifed

verified

Which Java keyword do we use in the constructor of a class inheriting from another class if we want to call the constructor of the inherited class?


A) call
B) super
C) constructor
D) clone

E) A) and C)
F) C) and D)

Correct Answer

verifed

verified

Which of the following cannot be an interface member?


A) A class
B) A constant
C) A mutator method
D) An abstract method

E) C) and D)
F) None of the above

Correct Answer

verifed

verified

Usually, an abstract class contains at least one abstract method.

A) True
B) False

Correct Answer

verifed

verified

Which of the following is true of polymorphism?


A) It simplifies the processing of various elements in the same class hierarchy.
B) To use polymorphism, the classes must be in a different hierarchy.
C) In Greek, the term means "many changes."
D) All of these are correct.

E) A) and D)
F) C) and D)

Correct Answer

verifed

verified

Typically, an abstract class is a class that is not completely implemented.

A) True
B) False

Correct Answer

verifed

verified

Suppose you write a program in which you attempt to use a subclass to directly access a private password field in a superclass. Predict what will happen, and suggest a solution that would result in a different outcome.

Correct Answer

verifed

verified

An attempt by a subclass to directly acc...

View Answer

Private fields and methods are part of the inheriting class object.

A) True
B) False

Correct Answer

verifed

verified

Some OOP developers call a subclass the base class and call a superclass the derived class.

A) True
B) False

Correct Answer

verifed

verified

Showing 21 - 40 of 61

Related Exams

Show Answer