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

The java.lang package contains fundamental classes and is imported automatically each time a program is written.

(True/False)
4.9/5
(35)

The Object class equals() method returns a boolean value indicating whether the objects are equal. This equals() method considers two objects to be equal only if they have the same ____________________ .

(Short Answer)
4.8/5
(40)

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

(Multiple Choice)
4.9/5
(35)

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

(Multiple Choice)
5.0/5
(44)

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 indicated statements in order to create a Honda class that extends Car . public class --Code here-- extends --Code here-- {     public void --Code here--     {        System.out.println("I like your red car!");     } }

(Essay)
4.9/5
(34)

____ is a calculated number that is used to uniquely identify an object.

(Multiple Choice)
4.9/5
(30)

Describe the two method types programmers of an abstract class can include.

(Essay)
4.8/5
(36)

An application's ability to select the correct subclass method is known as ____.

(Multiple Choice)
4.8/5
(29)

public abstract class Shape {     private int length;     private int width;     private int height;     ----Code here---- } Using the above code, create the statement in the place indicated that will create an abstract calculateArea() method in the abstract Shape class.

(Short Answer)
4.7/5
(33)

       The code above provides an example of an interface class. Explain the purpose and advantages of creating interfaces that store related constants.        The code above provides an example of an interface class. Explain the purpose and advantages of creating interfaces that store related constants. The code above provides an example of an interface class. Explain the purpose and advantages of creating interfaces that store related constants.

(Essay)
4.8/5
(35)

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

If you provide an empty method within an abstract class, the method is an abstract method even if you do not explicitly use the keyword ____________________ when defining the method.

(Short Answer)
4.8/5
(41)

While a class can inherit from multiple abstract superclasses, it implement only one interface.

(True/False)
4.9/5
(39)

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
(42)

What are the advantages to creating a useful, extendable superclass?

(Essay)
5.0/5
(43)

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

(Multiple Choice)
4.8/5
(40)

If you create an empty method within an abstract class, the method is abstract even if you do not explicitly use the keyword abstract.

(True/False)
4.9/5
(39)

Classes, such as the String class, have their own equals() methods that overload the ____ class method.

(Multiple Choice)
5.0/5
(42)

Java's Object class contains a public method named ____ that returns an integer representing the hash code.

(Multiple Choice)
4.8/5
(40)
Showing 41 - 60 of 66
close modal

Filters

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