Exam 9: Inheritance and Interfaces

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

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?

Free
(Multiple Choice)
4.9/5
(42)
Correct Answer:
Verified

D

A method that has no implementation is called a/an ____ method.

Free
(Multiple Choice)
4.9/5
(45)
Correct Answer:
Verified

D

You are creating a Motorcycle class which is supposed to use an interface named Measurable. Which of the following class declaration statements will accomplish this?

Free
(Multiple Choice)
4.9/5
(41)
Correct Answer:
Verified

B

Which of the following indicates that the Motorcycle class is a subclass of the Vehicle class?

(Multiple Choice)
4.9/5
(42)

Which of the following is true regarding subclasses?

(Multiple Choice)
5.0/5
(39)

A class from which you cannot create objects is called a/an ____.

(Multiple Choice)
4.9/5
(33)

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

You are creating a Vessel class which is supposed to use an interface named Measurable. Which of the following class declaration statements will accomplish this?

(Multiple Choice)
4.7/5
(44)

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

(Multiple Choice)
4.8/5
(40)

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

Consider the following code snippet: Public class BankAccount implements Comparable<BankAccount> { . . . Public int compareTo(T other) { What is wrong with this code?

(Multiple Choice)
4.9/5
(32)

Which of the following is true regarding subclasses?

(Multiple Choice)
4.7/5
(41)

Consider the following code snippet: Public class Score { Private String name; ) . . Public boolean equals(Object otherScore) { Return name.equals(otherScore.name); } ) . . } What is wrong with this code?

(Multiple Choice)
4.8/5
(41)

To ensure that an instance variable can only be accessed by the class that declared it, the variable should be declared as ____.

(Multiple Choice)
5.0/5
(35)

Consider the following code snippet: Public class Coin { ) . . Public boolean equals(Coin otherCoin) { ) . . } ) . . } What is wrong with this code?

(Multiple Choice)
4.8/5
(33)

When declared as protected, data in an object can be accessed by ____.

(Multiple Choice)
4.7/5
(44)

Consider the following code snippet: Public class Motorcycle extends Vehicle { Private String model; ) . . Public Motorcycle(int numberAxles, String modelName) { Model = modelName; Super(numberAxles); } } What does this code do?

(Multiple Choice)
4.9/5
(43)

Consider the following code snippet: Public interface Sizable { Double size; Double getSize(); } What is wrong with this code?

(Multiple Choice)
4.8/5
(36)

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

(Multiple Choice)
4.8/5
(34)

Consider the following code snippet: Public void deposit(double amount) { TransactionCount ++; Super.deposit(amount); } Which of the following statements is true?

(Multiple Choice)
4.9/5
(34)
Showing 1 - 20 of 99
close modal

Filters

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