Exam 10: Introduction to Inheritance

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

A class diagram consists of a rectangle divided into three sections.

(True/False)
4.7/5
(43)

What does polymorphism mean in Java programming?

(Essay)
4.7/5
(38)

If a ____ method has the same name as a parent class method and you use the name with a child class object, the child method hides the original.

(Multiple Choice)
4.9/5
(28)

It is useful to override the parent class members when the superclass data fields and methods are not completely appropriate for the subclass objects.

(True/False)
5.0/5
(41)

Write the statement to create a class header with a superclass-subclass relationship, with Vehicle as the superclass and Subaru as the subclass.

(Short Answer)
4.8/5
(30)

class InstanceofDemo {     public static void main(String[] args)    {         Parent object1 = new Parent();         Parent object2 = new Child();         System.out.println("object1 instanceof Parent: "             + (obj1 instanceof Parent));         System.out.println("object1 instanceof Child: "             + (obj1 instanceof Child));         System.out.println("object1 instanceof MyInterface: "             + (obj1 instanceof MyInterface));         System.out.println("object2 instanceof Parent: "             + (obj2 instanceof Parent));         System.out.println("object2 instanceof Child: "             + (obj2 instanceof Child));         System.out.println("object2 instanceof MyInterface: "             + (obj2 instanceof MyInterface));      } } The above code defines a parent class (named Parent ), a simple interface (named MyInterface ), and a child class (named Child ) that inherits from the parent and implements the interface. Following program execution, what will be the output of the six println statements?

(Essay)
4.8/5
(40)

Which of the following statements depicts the valid format to call a superclass constructor from a subclass constructor?

(Multiple Choice)
4.8/5
(31)

The ability to use inheritance in Java makes programs easier to write, ____, and more quickly understood.

(Multiple Choice)
4.9/5
(31)

   The UML diagram above derives a subclass called EmployeeWithTerritory from the superclass Employee . Describe what variables and methods the class EmployeeWithTerritory  inherits from the superclass Employee .  Also, describe any variables and public methods defined by the subclass EmployeeWithTerritory . The UML diagram above derives a subclass called EmployeeWithTerritory from the superclass Employee . Describe what variables and methods the class EmployeeWithTerritory  inherits from the superclass Employee .  Also, describe any variables and public methods defined by the subclass EmployeeWithTerritory .

(Essay)
4.7/5
(26)

Arrows used in a ____ to show inheritance relationships extend from the descendant class and point to the original class.

(Multiple Choice)
4.9/5
(36)

What is the difference between derived classes and base classes when considering two classes that inherit from each other?

(Essay)
4.7/5
(39)

The class used as a basis for inheritance is the ____ class.

(Multiple Choice)
4.8/5
(36)

Create a class named Employee with a name and a salary . Make a class named Manager that inherits from Employee with an instance field named department . Supply a toString() method that prints the manager's name, department, and salary. Make another class named Director that inherits from Manager with an instance field named stipendAmount . Supply the toString() method for Director that prints all of its instance variables. Also, write a program named myOutput that instantiates an object of each of the classes and invokes the toString() method of each of the objects.

(Essay)
4.8/5
(32)

Usually, the subclass constructor only needs to initialize the ____ that are specific to the subclass.

(Multiple Choice)
4.8/5
(36)

When you instantiate an object that is a member of a subclass, how many constructors are called?

(Essay)
4.7/5
(44)

A nonstatic method cannot  override a static member  of a parent class.

(True/False)
4.9/5
(38)

____ is a mechanism that enables one class to acquire all the behaviors and attributes of another class.

(Multiple Choice)
4.8/5
(40)

Which statement correctly declares a sedan object of the Car class?

(Multiple Choice)
4.8/5
(44)

How is the keyword protected used?

(Essay)
4.8/5
(33)

In a UML diagram, an inheritance relationship is indicated with an arrow that points from the original class  to the descendant class  .

(True/False)
4.8/5
(38)
Showing 41 - 60 of 66
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)