Exam 9: Inheritance

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

A class that cannot be instantiated is called a/an ____.

(Multiple Choice)
4.9/5
(38)

If a subclass contains a method with the same name as a method in its superclass, but with different parameter types, the subclass method is said to ____ the method of the superclass.

(Multiple Choice)
4.8/5
(38)

Which of the following statements about superclasses and subclasses is true?

(Multiple Choice)
4.8/5
(41)

If a subclass uses the same method name but different parameter types for a method that appears in its superclass, ____.

(Multiple Choice)
4.8/5
(39)

Consider the following code snippet: Int numAxles = 4; String s = "Number of axles is " + numAxles; Which of the following statements is correct?

(Multiple Choice)
4.7/5
(37)

Consider the hierarchy of classes shown below. Consider the hierarchy of classes shown below.   Which represent valid class headers that would be found in this hierarchy? Which represent valid class headers that would be found in this hierarchy?

(Multiple Choice)
4.8/5
(38)

Consider the following code snippet: Employee anEmployee = new Programmer(); AnEmployee.increaseSalary(2500); If the Programmer class inherits from the Employee class, and both classes have an implementation of the increaseSalary method with the same set of parameters and the same return type, which statement is correct?

(Multiple Choice)
4.8/5
(43)

Consider the classes shown below: public class Parent { Private int value = 100; Public int getValue() { Return value; } } Public class Child extends Parent { Private int value; Public Child(int number) { Value = number; } } What is the output of the following lines of code? Child kid = new Child(-14); Child kid2 = new Child(21); System.out.println(kid.getValue() + " " + kid2.getValue());

(Multiple Choice)
4.8/5
(36)

Consider the classes shown below: public class Parent { Public int getValue() { Return 24; } Public void display() { System.out.print(getValue() + " "); } } Public class Child extends Parent { Public int getValue() { Return -7; } } Using the classes above, what is the output of the following lines of code? Parent kid = new Child(); Parent adult = new Parent(); Kid)display(); Adult.display();

(Multiple Choice)
4.9/5
(27)

You are creating a class inheritance hierarchy about motor vehicles that will contain classes named Vehicle, Auto, and Motorcycle. Which of the following statements is correct?

(Multiple Choice)
4.7/5
(26)

You are creating a Motorcycle class which is supposed to inherit from the Vehicle class. Which of the following class declaration statements will accomplish this?

(Multiple Choice)
4.9/5
(35)

Consider the following class hierarchy: public class Vehicle { Private String type; Public Vehicle(String type) { This.type = type; } Public String getType() { Return type; } } Public class LandVehicle extends Vehicle { Public LandVehicle(String type) { ) . . } } Public class Auto extends LandVehicle { Public Auto(String type) { ) . . } } Which of the following code fragments is NOT valid in Java?

(Multiple Choice)
4.8/5
(32)

Consider the following code snippet: public class Vehicle { Private String manufacturer; ) . . Public void setVehicleClass(double numberAxles) { ) . . } } If a Motorcycle class is created as a subclass of the Vehicle class, which of the following statements is correct?

(Multiple Choice)
4.8/5
(45)

Consider the following code snippet: public class Auto extends Vehicle { ) . . Public Auto(int numberAxles) { Super(numberAxles); } } What does this code do?

(Multiple Choice)
4.9/5
(35)

Consider the following class hierarchy: public class Vehicle { Private String type; Public Vehicle(String type) { This.type = type; } Public String displayInfo() { Return type; } } Public class LandVehicle extends Vehicle { Public LandVehicle(String type) { ) . . } } Public class Auto extends LandVehicle { Public Auto(String type) { ) . . } Public String displayAutoType() { Return _____; } } Complete the code in the Auto class method named displayAutoType to return the type data.

(Multiple Choice)
4.9/5
(37)

Consider the Counter class below. public class Counter { Public int count = 0; Public int getCount() { Return count; } Public void increment() { Count++; } } Using the class above and the variables declared below, what is the value of num1.equals(num2)? Counter num1 = new Counter(); Counter num2 = num1;

(Multiple Choice)
4.9/5
(31)

With a few exceptions, instance variables of classes should always have ___ access.

(Multiple Choice)
4.9/5
(34)

Which of the following is true regarding inheritance?

(Multiple Choice)
4.8/5
(41)

Consider the following inheritance hierarchy diagram: Consider the following inheritance hierarchy diagram:   Which of the following statements is correct? Which of the following statements is correct?

(Multiple Choice)
4.9/5
(36)

Suppose the abstract class Message is defined below public abstract class Message { Private String value; Public Message(String initial) { Value = initial; } Public String getMessage() { Return value; } Public abstract String translate(); } A concrete subclass of Message, FrenchMessage, is defined. Which methods must FrenchMessage define?

(Multiple Choice)
4.7/5
(39)
Showing 61 - 80 of 101
close modal

Filters

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