Chapter 9
A class becomes abstract when you place the ________ key word in the class definition. Question options: A) final B) extends C) super D) abstract
Abstract
A protected member of a class may be directly accessed by Question options: A) methods of the same class. B) methods of a subclass. C) methods in the same package. D) All of these
All of these
In ________, inheritance is shown with a line that has an open arrowhead at one end that points to the superclass. Question options: A) hierarchy charts B) UML diagrams C) pseudocode D) CRC card
UML diagrams
All methods specified by an interface are Question options: A) public. B) private. C) static. D) protected.
public.
Protected class members can be denoted in a UML diagram with the ________ symbol. Question options: A) + B) - C) * D) #
#
Which of the following statements declares Salaried as a subclass of PayType? Question options: A) public class PayType derives Salaried B) public class Salaried implements PayType C) public class Salaried derivedFrom(Paytype) D) public class Salaried extends PayType
public class Salaried extends PayType
All fields declared in an interface Question options: A) have private access. B) have protected access. C) are treated as final and static. D) must be initialized in the class implementing the interface.
are treated as final and static.
When a method is declared with the ________ modifier, it cannot be overridden in a subclass. A) public B) super C) final D) void
final
When a class implements an interface, an inheritance relationship known as ________ is established. Question options: A) implemented heritage B) interface inheritance C) abstract inheritance D) realized inheritance
interface inheritance
Use the APIs to answer the following question. Which of the following classes is the direct parent class of the DecimalFormat class? Question options: Integer NumberFormat java.text Object
NumberFormat
What is wrong with the following code? class A{ protected char letter; public A(char l){ letter = l; } } class B extends A{ public B(){ super(); } } Question options: You need to state "this.letter" in the default constructor of class A. Both classes should be declared public. "protected" is not a valid access modifier. The default constructor for class A does not exist; Java will not create it automatically.
The default constructor for class A does not exist; Java will not create it automatically.
A subclass can directly access Question options: A) only protected and private members of the superclass. B) all members of the superclass. C) only public and private members of the superclass. D) only public and protected members of the superclass.
only public and protected members of the superclass.
Use the APIs to answer the following question. Which interface listed below does the String class implement? Question options: Iterable CharSequence java.lang Object
CharSequence
In the following statement, which is the superclass? Question options: A) ClassC B) ClassA C) ClassB and ClassC D) ClassB
Class B
This shows the inheritance relationships among classes in a manner that is similar to a family tree. Question options: A) class hierarchy B) flowchart C) CRC card D) UML diagram
Class hierarchy
In a class hierarchy, Question options: A) the more general classes are toward the top of the tree and the more specialized classes are toward the bottom. B) the more general classes are toward the bottom of the tree and the more specialized classes are toward the top. C) the more general classes are toward the left of the tree and the more specialized classes are toward the right. D) the more general classes are toward the right of the tree and the more specialized classes are toward the left.
the more general classes are toward the top of the tree and the more specialized classes are toward the bottom.
In Java, a reference variable is ________ because it can reference objects of types different from its own, as long as those types are related to its type through inheritance. Question options: A) dynamic B) polymorphic C) static D) public
polymorphic
In object-oriented programming, ________ allows you to extend the capabilities of a class by creating another class that is a specialized version of it. A) data hiding B) prototyping C) inheritance D) code reusability
inheritance