Exam 10: Introduction to Inheritance

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

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

(Multiple Choice)
4.9/5
(39)

The classes you create in ____________________ programming languages can inherit data and methods from existing classes.

(Short Answer)
4.9/5
(44)

When you employ ____, your data can be altered only by the methods you choose and only in ways that you can control.

(Multiple Choice)
4.8/5
(39)

If a programming language does not support ____, the language is not considered object-oriented.

(Multiple Choice)
4.7/5
(38)

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.9/5
(38)

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.9/5
(41)

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
(43)

Match each term with the correct statement below. -Inherits from a base class

(Multiple Choice)
4.8/5
(33)

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

(Multiple Choice)
4.7/5
(38)

When you create parent and child classes of your own, the child classes use ____ constructors.

(Multiple Choice)
4.9/5
(31)

Superclasses can be distinguished from their subclasses because a subclass is generally smaller than a superclass; it usually has fewer fields and methods.

(True/False)
4.9/5
(40)

Java's Math class is an example of a protected class.

(True/False)
4.7/5
(37)

In a UML diagram, minus signs are inserted in front of each private field or method, and plus signs are inserted in front of each public field or method.

(True/False)
4.7/5
(32)

Match each term with the correct statement below. -Determines whether an object is a member or descendant of a class

(Multiple Choice)
4.7/5
(42)

What are the parts of a class diagram and how would you use them?

(Essay)
4.8/5
(36)

Match each term with the correct statement below. -A mechanism that enables one class to assume both the behavior and the attributes of another class

(Multiple Choice)
4.8/5
(34)

class Animal { void myDog() { System.out.println("Animal stuff"); } } class Dog extends Animal { void mydog() { System.out.println("Dog stuff"); } public static void main(String args[]) { Dog d = new Dog(); d.myDog(); super.myDog(); } } The above code gives a compiler error stating that the non-static variable super cannot be referenced from a static context super.myDog();. Explain why the error occurs and describe what changes you could make for the code to be executable.

(Essay)
4.9/5
(31)

Sometimes the superclass data fields and methods are not entirely appropriate for the subclass objects; in these cases, you want to ____ the parent class members.

(Multiple Choice)
4.8/5
(44)

When you use the method name with a child object, the parent's version of the method is used.

(True/False)
4.9/5
(39)

By convention, a class diagram contains the ____ following each attribute or method.

(Multiple Choice)
4.9/5
(39)
Showing 21 - 40 of 70
close modal

Filters

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