Exam 11: Advanced Inheritance Concepts

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

public abstract class Car { private String model; public abstract void color(); public String getModel() { return model; } public void setModel(String modelName) { model = modelName; } } public class Honda extends Car { public void color() { System.out.println("red"); } } public class Ford extends Car { public void color() { System.out.println("blue"); } } public class MyCars { public static void main(String[] args) { Honda myHonda = new Honda(); Ford myFord = new Ford(); myHonda.setModel("My Honda is "); myFord.setModel("My Ford is "); System.out.print(myHonda.getModel()); myHonda.color(); System.out.print(myFord.getModel()); myFord.color(); } } Using the above code, describe the output that will appear when the program is executed.

(Essay)
4.7/5
(36)

When you create a new subclass in Java, neither the superclass source code nor the superclass _____ is changed.

(Multiple Choice)
4.8/5
(31)

The Object class equals() method returns a(n) ____ value indicating whether the objects are equal.

(Multiple Choice)
4.9/5
(48)

Java does not allow a class to inherit directly from two or more parents.

(True/False)
4.9/5
(39)

When you create a subclass of an abstract class, it's important to understand that you are required to code a subclass method to override the empty superclass method that is inherited.

(True/False)
5.0/5
(35)

When you create a number of classes that inherit from each other, as well as multiple interfaces that you want to implement with these classes, you often will find it convenient to place these related classes in a(n) ____________________.

(Short Answer)
4.9/5
(38)

Compare and contrast abstract classes and interfaces.

(Essay)
4.7/5
(33)

Match each term with the correct statement below. -A concrete class that extends the abstract class Calendar

(Multiple Choice)
4.8/5
(35)

Match each term with the correct statement below. -The correct subclass method is attached to the application

(Multiple Choice)
4.7/5
(47)

What is dynamic method binding and why is it used?

(Essay)
4.8/5
(36)

Give an example of how you can create an interface to have a class implement behavior from more than one parent.

(Essay)
4.9/5
(34)

When you create a class that uses an interface, you include the keyword extends.

(True/False)
4.7/5
(34)

Match each term with the correct statement below. -Considers two objects of the same class to be equal only if they have the same hash code

(Multiple Choice)
4.9/5
(36)

In the Java programming language, a package or class library is often delivered to users as a(n) ____________________ file.

(Short Answer)
4.9/5
(39)

A(n) ____ class is one from which you cannot create any concrete objects, but from which you can inherit.

(Multiple Choice)
4.9/5
(36)

When a class both extends and implements, by convention the ____ clause is last in the class header.

(Multiple Choice)
4.7/5
(39)

Match each term with the correct statement below. -An alternative to multiple inheritance available in Java

(Multiple Choice)
4.8/5
(39)

A(n) ____ looks much like a class, except that all of its methods (if any) are implicitly public and abstract.

(Multiple Choice)
4.7/5
(47)

What is an abstract class? Give an example and explain how it works.

(Essay)
4.8/5
(45)

public interface FindTheError { void firstMethod(int anIntNum) { System.out.println("Did you find the error?"); } } What is the problem with the above interface? How would you correct the interface?

(Essay)
4.7/5
(35)
Showing 21 - 40 of 70
close modal

Filters

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