Exam 11: Advanced Inheritance Concepts

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

It is common to create an interface when you want a class to implement behavior from more than one parent.

(True/False)
4.9/5
(33)

Why do many programmers consider multiple inheritance to be a difficult concept?

(Essay)
4.8/5
(34)

When you assign a variable or constant of one type to a variable of another type, the behavior is called ____.

(Multiple Choice)
4.7/5
(34)

While a class can inherit from any abstract superclass, it can only implement one interface.

(True/False)
4.8/5
(46)

public abstract class Car { private String model; public abstract void color(); public String getModel() { return model; } public void setModel(String modelName) { model = modelName; } } The above code creates a generic abstract class named Car with an abstract color() method. Using the code below, fill in the shaded statements in order to create a Honda class that extends Car. public class ____ extends ____ { public void ____ { System.out.println("I like your red car!"); } }

(Essay)
4.8/5
(41)

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(); } } In the above code, the myHonda.getModel() and myHonda.color() method calls produce different output from when the same methods are used with myFord. Explain why this is the case.

(Essay)
4.9/5
(32)

____ compress the data they store, which reduces the size of archived class files.

(Multiple Choice)
4.9/5
(45)

The Object class ____ method converts an Object into a String that contains information about the Object.

(Multiple Choice)
4.9/5
(47)

In other programming languages, such as C++, abstract classes are known as ____________________ classes.

(Short Answer)
4.8/5
(38)

public abstract class Car { private String model; public abstract void color(); public String getName() { return model; } public void setName(String carModel) { model = carModel; } } Using the code above, would it be possible to create a class in which you declare a Car object with the statement Car myCar = new Car("Honda");? Explain why or why not.

(Essay)
4.8/5
(42)
Showing 61 - 70 of 70
close modal

Filters

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