Big Java Binder Early Objects

Computing

Quiz 9 :

Inheritance

Quiz 9 :

Inheritance

Question Type
search
arrow
Consider the classes shown below: public class Parent { Public void doSomething(){/* Implementation not shown */} } Public class Child extends Parent { Public void doAnotherThing(){/* Implementation not shown */} } Which lines in the following code will compile without error? Child kid = new Child(); Kid)doSomething(); // line 1 Kid)doAnotherThing(); // line 2
Free
Multiple Choice
Answer:

Answer:

C

Tags
Choose question tag
close menu
arrow
Suppose the class Message is partially defined as shown below public class Message { Private String value; Public Message(String initial) { Value = initial; } Public String getMessage() { Return value; } } A subclass of Message, ExcitedMessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses ExcitedMessage is shown below. ExcitedMessage greeting = new ExcitedMessage("Hello"); System.out.print(greeting.getMessage()); // will print "Hello!!" Which ExcitedMessage constructor will give this behavior?
Free
Multiple Choice
Answer:

Answer:

A

Tags
Choose question tag
close menu
arrow
Consider the following inheritance hierarchy diagram: img Which of the following statements is correct?
Free
Multiple Choice
Answer:

Answer:

A

Tags
Choose question tag
close menu
arrow
A class that represents a more specific entity in an inheritance hierarchy is called a/an ____.
Multiple Choice
Answer:
Tags
Choose question tag
close menu
arrow
Consider the hierarchy of classes shown below. img What is the superclass of the class TelevisionShow?
Multiple Choice
Answer:
Tags
Choose question tag
close menu
arrow
Which of the following statements about inheritance is correct?
Multiple Choice
Answer:
Tags
Choose question tag
close menu
arrow
Consider the following inheritance hierarchy diagram: img Which of the following statements is correct?
Multiple Choice
Answer:
Tags
Choose question tag
close menu
arrow
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); Parent adult = new Parent(); System.out.println(kid.getValue() + " " + adult.getValue());
Multiple Choice
Answer:
Tags
Choose question tag
close menu
arrow
Suppose the class Value is partially defined below public class Value { Private int number; Public int getValue() { Return number; } } A subclass of Value, LargerValue, is defined with a getValue method that returns twice the value of the parent. Which line is the body of LargerValue's getValue method?
Multiple Choice
Answer:
Tags
Choose question tag
close menu
arrow
All rodents are mammals and all canines are mammals. No canines are rodents and no rodents are canines. What hierarchy best captures this information?
Multiple Choice
Answer:
Tags
Choose question tag
close menu
arrow
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); Parent kid2 = new Child(21); System.out.println(kid.getValue() + " " + kid2.getValue());
Multiple Choice
Answer:
Tags
Choose question tag
close menu
arrow
Insert the missing code in the following code fragment. This fragment is intended to call the Vehicle class's method. public class Vehicle { ) . . Public void setVehicleClass(double numberAxles) { ) . . } } Public class Motorcycle extends Vehicle { ) . . Public Motorcycle() { _______________; } }
Multiple Choice
Answer:
Tags
Choose question tag
close menu
arrow
Consider the hierarchy of classes shown below. img Which represent valid class headers that would be found in this hierarchy?
Multiple Choice
Answer:
Tags
Choose question tag
close menu
arrow
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
Answer:
Tags
Choose question tag
close menu
arrow
Consider the hierarchy of classes shown below. img What is the superclass of the class ScriptedShow?
Multiple Choice
Answer:
Tags
Choose question tag
close menu
arrow
Consider the classes shown below: public class Parent { Public void doSomething(){/* Implementation not shown */} } Public class Child extends Parent { Public void doAnotherThing(){/* Implementation not shown */} } Which lines in the following code will compile without error? Parent kid = new Child(); Kid)doSomething(); // line 1 Kid)doAnotherThing(); // line 2
Multiple Choice
Answer:
Tags
Choose question tag
close menu
arrow
Insert the missing code in the following code fragment. This fragment is intended to call the Vessel class's method. public class Vessel { ) . . Public void set VesselClass(double vesselLength) { ) . . } } Public class SpeedBoat extends Vessel { ) . . Public SpeedBoat() { _______________; } }
Multiple Choice
Answer:
Tags
Choose question tag
close menu
arrow
All hamsters are rodents and all rodents are mammals. What hierarchy best captures this information?
Multiple Choice
Answer:
Tags
Choose question tag
close menu
arrow
A class that represents the most general entity in an inheritance hierarchy is called a/an ____.
Multiple Choice
Answer:
Tags
Choose question tag
close menu
arrow
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
Answer:
Tags
Choose question tag
close menu
Showing 1 - 20 of 101