Exam 11: Advanced Inheritance Concepts

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

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

(True/False)
5.0/5
(34)

public class Animal { } public class Animal extends Object { } The two class declarations above have identical outcomes. Explains why this is the case.

(Essay)
4.9/5
(37)

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

(True/False)
4.8/5
(43)

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.

(Multiple Choice)
4.7/5
(39)

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

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

(Multiple Choice)
4.9/5
(39)
Match each term with the correct statement below.
Premises:
A number that uniquely identifies an object
Responses:
lambda expression
nonabstract method
multiple inheritance
Correct Answer:
Verified
Premises:
Responses:
A number that uniquely identifies an object
lambda expression
(Matching)
4.8/5
(36)

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

Instead of using the automatic toString() method with your classes, it is usually more useful to write your own ____ version of the toString() method that displays some or all of the data field values for the object with which you use it.

(Multiple Choice)
4.8/5
(43)

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

(True/False)
4.8/5
(37)

A functional interface ____.

(Multiple Choice)
5.0/5
(38)

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

(Multiple Choice)
4.8/5
(39)

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

    The equals() method returns a boolean value indicating whether two objects are equal. Using the above code, will the two BankAccount objects be equal? Explain why or why not.     The equals() method returns a boolean value indicating whether two objects are equal. Using the above code, will the two BankAccount objects be equal? Explain why or why not. The equals() method returns a boolean value indicating whether two objects are equal. Using the above code, will the two BankAccount objects be equal? Explain why or why not.

(Essay)
4.9/5
(34)

The capability to inherit from more than one class is called ____.

(Multiple Choice)
4.8/5
(37)

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

(Multiple Choice)
4.9/5
(33)

Compare and contrast abstract classes and interfaces.

(Essay)
4.8/5
(38)

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

(Multiple Choice)
4.8/5
(30)

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

(True/False)
4.9/5
(35)

When a superclass is abstract, you cannot instantiate objects of a superclass. How can you use a superclass abstract object?

(Essay)
4.7/5
(33)
Showing 21 - 40 of 78
close modal

Filters

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