Deck 11: Advanced Inheritance Concepts

Full screen (f)
exit full mode
Question
When you assign a variable or constant of one type to a variable of another type, the behavior is called ____.

A) implicit conversion
B) referencing
C) dynamic method binding
D) containing
Use Space or
up arrow
down arrow
to flip the card.
Question
If you attempt to instantiate an object from an abstract class, you receive an error message from the compiler that you have committed a(n) ____.

A) LogicError
B) InstantiationError
C) SyntaxError
D) ObjectError
Question
If you create an empty method within an abstract class, the method is abstract even if you do not explicitly use the keyword abstract.
Question
The java.lang package contains fundamental classes and is imported automatically each time a program is written.
Question
Which of the following statements creates an array of three Animal references?

A) Animal[] ref = new Animal(3);
B) Animal[] new = ref Animal[3];
C) Animal[] animalRef = new Animal[3];
D) Animal[] ref = extend Animal[3];
Question
When you define a class, if you do not explicitly extend another class, your class is an extension of the ____ class.

A) Object
B) super
C) public
D) abstract
Question
While a class can inherit from multiple abstract superclasses, it can implement only one interface.
Question
A(n) ____ is not an object, but it points to a memory address.

A) abstract class
B) reference
C) extend
D) interface
Question
You sometimes create an abstract class only so you can ____ it to another class.

A) link
B) copy
C) extend
D) abstract
Question
Java does not allow a class to inherit directly from two or more parents.
Question
An application's ability to select the correct subclass method is known as ____.

A) implementing methods
B) dynamic method binding
C) implicit casting
D) method fixing
Question
Classes from which objects can be instantiated are called constant classes.
Question
When you create a class that uses an interface, you include the keyword extends .
Question
Abstract classes and interfaces are similar in that you cannot instantiate concrete objects from either one.
Question
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.

A) overloaded
B) protected
C) static
D) condensed
Question
When you create a superclass and one or more subclasses, each object of each subclass is a subclass object.
Question
The Object class ____ method converts an Object into a String that contains information about the Object .

A) equals()
B) setType()
C) toString()
D) speak()
Question
A class that will be placed in a nondefault package for others to use must be private .
Question
A(n) ____ class is a class that you create only to extend from.

A) abstract
B) inheritance
C) parent
D) final
Question
It is common to create an interface when you want a class to implement behavior from more than one parent.
Question
If Java did not allow you to ____ classes, you would need to create every part of a program from scratch.

A) extend
B) override
C) abstract
D) import
Question
When you create a new subclass in Java, neither the superclass source code nor the superclass ____ is changed.

A) bytecode
B) object
C) argument
D) possession
Question
____ compress the data they store, which reduces the size of archived class files.

A) Dynamic method bindings
B) JAR files
C) Type-import-on-demand declarations
D) Interfaces
Question
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.

A) virtual
B) implements
C) abstract
D) extends
Question
Classes, such as the String class, have their own equals() methods that overload the ____ class method.

A) Object
B) Public
C) Abstract
D) Child
Question
When you create a class and use the implements clause to implement an interface but fail to code one of the interface's methods, the compiler error generated indicates that you must declare your class to be ____.

A) abstract
B) static
C) public
D)   new
Question
The ____ method is useful in debugging a program because it can be used to display and examine values.

A) finalize()
B) toString()
C) notify()
D) equals()
Question
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) ____.

A) group
B) package
C) abstract class
D) file
Question
A(n) ____ looks much like a class, except that all of its methods (if any) are implicitly public and abstract.

A) hash code
B) package
C) collision
D) interface
Question
____ is a calculated number that is used to uniquely identify an object.

A) Method binding
B) A hash code
C) Implicit conversion
D) Ad-hoc polymorphism
Question
The capability to inherit from more than one class is called ____.

A) multiple inheritance
B) collision
C) polyinheritance
D) dynamic method binding
Question
When you show abstract classes and methods in class diagrams, their names appear in ____.

A) bold
B) all caps
C) italics
D) blue
Question
The Object class equals() method returns a(n) ____ value indicating whether the objects are equal.

A) int
B) equals
C) null
D) boolean
Question
When a class both extends and implements , by convention the ____ clause follows the keyword  extends  in the class header.

A) extends
B) new
C) implements
D) if
Question
If you do not specify a package for a class, it is placed in an unnamed ____ package.

A) system
B) language
C) default
D) general
Question
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 ____.

A) address
B) value
C) hash code
D) number of characters
Question
Which of the following is NOT true regarding abstract methods?

A) Abstract methods must be implemented in child classes.
B) Abstract methods have no body.
C) Abstract methods use the abstract keyword in declarations.
D) Abstract methods are inherited by their children.
Question
In other programming languages, such as C++, abstract classes are known as ____ classes.

A) anonymous
B) pseudo
C) simulated
D) virtual
Question
Java's Object class contains a public method named ____ that returns an integer representing the hash code.

A) length()
B) hashCode()
C) hcode()
D) toString()
Question
In the Java programming language, a package or class library is often delivered to users as a(n) ____ file.

A) JAR
B) interface
C) .java
D) class
Question
What is the toString() method used for and how is it used?
Question
A functional interface ____.

A) is the same as a package
B) can have multiple lambda expressions
C) contains just one abstract method
D) can only contain  effectively final variables
Question
Match between columns
similar to a Zip file
dynamic method binding
similar to a Zip file
collision
similar to a Zip file
virtual classes
similar to a Zip file
multiple inheritance
similar to a Zip file
equals() method
similar to a Zip file
nonabstract method
similar to a Zip file
java.lang
similar to a Zip file
public , static , and final
similar to a Zip file
interface
similar to a Zip file
concrete class
similar to a Zip file
hash code
similar to a Zip file
anonymous inner class
similar to a Zip file
lambda expression
similar to a Zip file
JAR file
similar to a Zip file
functional interface
Question
Match between columns
Data fields in an interface
dynamic method binding
Data fields in an interface
collision
Data fields in an interface
virtual classes
Data fields in an interface
multiple inheritance
Data fields in an interface
equals() method
Data fields in an interface
nonabstract method
Data fields in an interface
java.lang
Data fields in an interface
public , static , and final
Data fields in an interface
interface
Data fields in an interface
concrete class
Data fields in an interface
hash code
Data fields in an interface
anonymous inner class
Data fields in an interface
lambda expression
Data fields in an interface
JAR file
Data fields in an interface
functional interface
Question
What is dynamic method binding and why is it used?
Question
Match between columns
Creates an object that implements a functional interface
dynamic method binding
Creates an object that implements a functional interface
collision
Creates an object that implements a functional interface
virtual classes
Creates an object that implements a functional interface
multiple inheritance
Creates an object that implements a functional interface
equals() method
Creates an object that implements a functional interface
nonabstract method
Creates an object that implements a functional interface
java.lang
Creates an object that implements a functional interface
public , static , and final
Creates an object that implements a functional interface
interface
Creates an object that implements a functional interface
concrete class
Creates an object that implements a functional interface
hash code
Creates an object that implements a functional interface
anonymous inner class
Creates an object that implements a functional interface
lambda expression
Creates an object that implements a functional interface
JAR file
Creates an object that implements a functional interface
functional interface
Question
Match between columns
Prohibited in Java
dynamic method binding
Prohibited in Java
collision
Prohibited in Java
virtual classes
Prohibited in Java
multiple inheritance
Prohibited in Java
equals() method
Prohibited in Java
nonabstract method
Prohibited in Java
java.lang
Prohibited in Java
public , static , and final
Prohibited in Java
interface
Prohibited in Java
concrete class
Prohibited in Java
hash code
Prohibited in Java
anonymous inner class
Prohibited in Java
lambda expression
Prohibited in Java
JAR file
Prohibited in Java
functional interface
Question
Match between columns
Has no name and is defined inside another class
dynamic method binding
Has no name and is defined inside another class
collision
Has no name and is defined inside another class
virtual classes
Has no name and is defined inside another class
multiple inheritance
Has no name and is defined inside another class
equals() method
Has no name and is defined inside another class
nonabstract method
Has no name and is defined inside another class
java.lang
Has no name and is defined inside another class
public , static , and final
Has no name and is defined inside another class
interface
Has no name and is defined inside another class
concrete class
Has no name and is defined inside another class
hash code
Has no name and is defined inside another class
anonymous inner class
Has no name and is defined inside another class
lambda expression
Has no name and is defined inside another class
JAR file
Has no name and is defined inside another class
functional interface
Question
Match between columns
The correct subclass method is attached to the application
dynamic method binding
The correct subclass method is attached to the application
collision
The correct subclass method is attached to the application
virtual classes
The correct subclass method is attached to the application
multiple inheritance
The correct subclass method is attached to the application
equals() method
The correct subclass method is attached to the application
nonabstract method
The correct subclass method is attached to the application
java.lang
The correct subclass method is attached to the application
public , static , and final
The correct subclass method is attached to the application
interface
The correct subclass method is attached to the application
concrete class
The correct subclass method is attached to the application
hash code
The correct subclass method is attached to the application
anonymous inner class
The correct subclass method is attached to the application
lambda expression
The correct subclass method is attached to the application
JAR file
The correct subclass method is attached to the application
functional interface
Question
What is an abstract class? Give an example and explain how it works.
Question
Match between columns
A method that is inherited
dynamic method binding
A method that is inherited
collision
A method that is inherited
virtual classes
A method that is inherited
multiple inheritance
A method that is inherited
equals() method
A method that is inherited
nonabstract method
A method that is inherited
java.lang
A method that is inherited
public , static , and final
A method that is inherited
interface
A method that is inherited
concrete class
A method that is inherited
hash code
A method that is inherited
anonymous inner class
A method that is inherited
lambda expression
A method that is inherited
JAR file
A method that is inherited
functional interface
Question
Match between columns
Contains just one abstract method
dynamic method binding
Contains just one abstract method
collision
Contains just one abstract method
virtual classes
Contains just one abstract method
multiple inheritance
Contains just one abstract method
equals() method
Contains just one abstract method
nonabstract method
Contains just one abstract method
java.lang
Contains just one abstract method
public , static , and final
Contains just one abstract method
interface
Contains just one abstract method
concrete class
Contains just one abstract method
hash code
Contains just one abstract method
anonymous inner class
Contains just one abstract method
lambda expression
Contains just one abstract method
JAR file
Contains just one abstract method
functional interface
Question
When a superclass is abstract, you cannot instantiate objects of a superclass. How can you use a superclass abstract object?
Question
Match between columns
A number that uniquely identifies an object
dynamic method binding
A number that uniquely identifies an object
collision
A number that uniquely identifies an object
virtual classes
A number that uniquely identifies an object
multiple inheritance
A number that uniquely identifies an object
equals() method
A number that uniquely identifies an object
nonabstract method
A number that uniquely identifies an object
java.lang
A number that uniquely identifies an object
public , static , and final
A number that uniquely identifies an object
interface
A number that uniquely identifies an object
concrete class
A number that uniquely identifies an object
hash code
A number that uniquely identifies an object
anonymous inner class
A number that uniquely identifies an object
lambda expression
A number that uniquely identifies an object
JAR file
A number that uniquely identifies an object
functional interface
Question
Match between columns
An alternative to multiple inheritance available in Java
dynamic method binding
An alternative to multiple inheritance available in Java
collision
An alternative to multiple inheritance available in Java
virtual classes
An alternative to multiple inheritance available in Java
multiple inheritance
An alternative to multiple inheritance available in Java
equals() method
An alternative to multiple inheritance available in Java
nonabstract method
An alternative to multiple inheritance available in Java
java.lang
An alternative to multiple inheritance available in Java
public , static , and final
An alternative to multiple inheritance available in Java
interface
An alternative to multiple inheritance available in Java
concrete class
An alternative to multiple inheritance available in Java
hash code
An alternative to multiple inheritance available in Java
anonymous inner class
An alternative to multiple inheritance available in Java
lambda expression
An alternative to multiple inheritance available in Java
JAR file
An alternative to multiple inheritance available in Java
functional interface
Question
Match between columns
A class-naming conflict
dynamic method binding
A class-naming conflict
collision
A class-naming conflict
virtual classes
A class-naming conflict
multiple inheritance
A class-naming conflict
equals() method
A class-naming conflict
nonabstract method
A class-naming conflict
java.lang
A class-naming conflict
public , static , and final
A class-naming conflict
interface
A class-naming conflict
concrete class
A class-naming conflict
hash code
A class-naming conflict
anonymous inner class
A class-naming conflict
lambda expression
A class-naming conflict
JAR file
A class-naming conflict
functional interface
Question
Match between columns
Considers two objects of the same class to be equal only if they have the same hash code
dynamic method binding
Considers two objects of the same class to be equal only if they have the same hash code
collision
Considers two objects of the same class to be equal only if they have the same hash code
virtual classes
Considers two objects of the same class to be equal only if they have the same hash code
multiple inheritance
Considers two objects of the same class to be equal only if they have the same hash code
equals() method
Considers two objects of the same class to be equal only if they have the same hash code
nonabstract method
Considers two objects of the same class to be equal only if they have the same hash code
java.lang
Considers two objects of the same class to be equal only if they have the same hash code
public , static , and final
Considers two objects of the same class to be equal only if they have the same hash code
interface
Considers two objects of the same class to be equal only if they have the same hash code
concrete class
Considers two objects of the same class to be equal only if they have the same hash code
hash code
Considers two objects of the same class to be equal only if they have the same hash code
anonymous inner class
Considers two objects of the same class to be equal only if they have the same hash code
lambda expression
Considers two objects of the same class to be equal only if they have the same hash code
JAR file
Considers two objects of the same class to be equal only if they have the same hash code
functional interface
Question
Match between columns
Contains the Object class
dynamic method binding
Contains the Object class
collision
Contains the Object class
virtual classes
Contains the Object class
multiple inheritance
Contains the Object class
equals() method
Contains the Object class
nonabstract method
Contains the Object class
java.lang
Contains the Object class
public , static , and final
Contains the Object class
interface
Contains the Object class
concrete class
Contains the Object class
hash code
Contains the Object class
anonymous inner class
Contains the Object class
lambda expression
Contains the Object class
JAR file
Contains the Object class
functional interface
Question
Match between columns
Allows object instantiation
dynamic method binding
Allows object instantiation
collision
Allows object instantiation
virtual classes
Allows object instantiation
multiple inheritance
Allows object instantiation
equals() method
Allows object instantiation
nonabstract method
Allows object instantiation
java.lang
Allows object instantiation
public , static , and final
Allows object instantiation
interface
Allows object instantiation
concrete class
Allows object instantiation
hash code
Allows object instantiation
anonymous inner class
Allows object instantiation
lambda expression
Allows object instantiation
JAR file
Allows object instantiation
functional interface
Question
Match between columns
The name given to abstract classes in other programming languages, such as C++
dynamic method binding
The name given to abstract classes in other programming languages, such as C++
collision
The name given to abstract classes in other programming languages, such as C++
virtual classes
The name given to abstract classes in other programming languages, such as C++
multiple inheritance
The name given to abstract classes in other programming languages, such as C++
equals() method
The name given to abstract classes in other programming languages, such as C++
nonabstract method
The name given to abstract classes in other programming languages, such as C++
java.lang
The name given to abstract classes in other programming languages, such as C++
public , static , and final
The name given to abstract classes in other programming languages, such as C++
interface
The name given to abstract classes in other programming languages, such as C++
concrete class
The name given to abstract classes in other programming languages, such as C++
hash code
The name given to abstract classes in other programming languages, such as C++
anonymous inner class
The name given to abstract classes in other programming languages, such as C++
lambda expression
The name given to abstract classes in other programming languages, such as C++
JAR file
The name given to abstract classes in other programming languages, such as C++
functional interface
Question
  The shaded header of the talkingAnimal() method accepts any type of Animal argument. Explain how this is possible.<div style=padding-top: 35px> The shaded header of the talkingAnimal() method accepts any type of Animal argument. Explain how this is possible.
Question
Compare and contrast abstract classes and interfaces.
Question
Why do many programmers consider multiple inheritance to be a difficult concept?
Question
How is the Object class equals() method implemented?
Question
    The code above provides an example of an interface class. Explain the purpose and advantages of creating interfaces that store related constants.<div style=padding-top: 35px>     The code above provides an example of an interface class. Explain the purpose and advantages of creating interfaces that store related constants.<div style=padding-top: 35px> The code above provides an example of an interface class. Explain the purpose and advantages of creating interfaces that store related constants.
Question
Describe the two method types programmers of an abstract class can include.
Question
public class Animal
{
}
public class Animal extends Object
{
}
The two class declarations above have identical outcomes. Explains why this is the case.
Question
    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.<div style=padding-top: 35px>     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.<div style=padding-top: 35px> 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.
Question
Give an example of how you can create an interface to have a class implement behavior from more than one parent.
Question
When you create classes for others to use, why would you not want to provide the users with your source code in the files with .java extensions?
Question
  The AnimalReference application shown above contains a generic Animal reference variable into which you can assign concrete Animal objects. Explain how this example uses polymorphism and why it is important.<div style=padding-top: 35px> The AnimalReference application shown above contains a generic Animal reference variable into which you can assign concrete Animal objects. Explain how this example uses polymorphism and why it is important.
Question
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?
Question
When you create a useful, extendable superclass, you and other future programmers gain what advantages?
Question
  An array can be created to reserve space for references to objects. Using the code above, explain how an array of superclass references can hold subclass references.<div style=padding-top: 35px> An array can be created to reserve space for references to objects. Using the code above, explain how an array of superclass references can hold subclass references.
Question
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.
Question
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.
Question
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.
Question
What are the advantages to creating a useful, extendable superclass?
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/78
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 11: Advanced Inheritance Concepts
1
When you assign a variable or constant of one type to a variable of another type, the behavior is called ____.

A) implicit conversion
B) referencing
C) dynamic method binding
D) containing
A
2
If you attempt to instantiate an object from an abstract class, you receive an error message from the compiler that you have committed a(n) ____.

A) LogicError
B) InstantiationError
C) SyntaxError
D) ObjectError
B
3
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
4
The java.lang package contains fundamental classes and is imported automatically each time a program is written.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following statements creates an array of three Animal references?

A) Animal[] ref = new Animal(3);
B) Animal[] new = ref Animal[3];
C) Animal[] animalRef = new Animal[3];
D) Animal[] ref = extend Animal[3];
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
6
When you define a class, if you do not explicitly extend another class, your class is an extension of the ____ class.

A) Object
B) super
C) public
D) abstract
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
7
While a class can inherit from multiple abstract superclasses, it can implement only one interface.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
8
A(n) ____ is not an object, but it points to a memory address.

A) abstract class
B) reference
C) extend
D) interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
9
You sometimes create an abstract class only so you can ____ it to another class.

A) link
B) copy
C) extend
D) abstract
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
10
Java does not allow a class to inherit directly from two or more parents.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
11
An application's ability to select the correct subclass method is known as ____.

A) implementing methods
B) dynamic method binding
C) implicit casting
D) method fixing
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
12
Classes from which objects can be instantiated are called constant classes.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
13
When you create a class that uses an interface, you include the keyword extends .
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
14
Abstract classes and interfaces are similar in that you cannot instantiate concrete objects from either one.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
15
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.

A) overloaded
B) protected
C) static
D) condensed
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
16
When you create a superclass and one or more subclasses, each object of each subclass is a subclass object.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
17
The Object class ____ method converts an Object into a String that contains information about the Object .

A) equals()
B) setType()
C) toString()
D) speak()
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
18
A class that will be placed in a nondefault package for others to use must be private .
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
19
A(n) ____ class is a class that you create only to extend from.

A) abstract
B) inheritance
C) parent
D) final
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
20
It is common to create an interface when you want a class to implement behavior from more than one parent.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
21
If Java did not allow you to ____ classes, you would need to create every part of a program from scratch.

A) extend
B) override
C) abstract
D) import
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
22
When you create a new subclass in Java, neither the superclass source code nor the superclass ____ is changed.

A) bytecode
B) object
C) argument
D) possession
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
23
____ compress the data they store, which reduces the size of archived class files.

A) Dynamic method bindings
B) JAR files
C) Type-import-on-demand declarations
D) Interfaces
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
24
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.

A) virtual
B) implements
C) abstract
D) extends
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
25
Classes, such as the String class, have their own equals() methods that overload the ____ class method.

A) Object
B) Public
C) Abstract
D) Child
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
26
When you create a class and use the implements clause to implement an interface but fail to code one of the interface's methods, the compiler error generated indicates that you must declare your class to be ____.

A) abstract
B) static
C) public
D)   new
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
27
The ____ method is useful in debugging a program because it can be used to display and examine values.

A) finalize()
B) toString()
C) notify()
D) equals()
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
28
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) ____.

A) group
B) package
C) abstract class
D) file
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
29
A(n) ____ looks much like a class, except that all of its methods (if any) are implicitly public and abstract.

A) hash code
B) package
C) collision
D) interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
30
____ is a calculated number that is used to uniquely identify an object.

A) Method binding
B) A hash code
C) Implicit conversion
D) Ad-hoc polymorphism
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
31
The capability to inherit from more than one class is called ____.

A) multiple inheritance
B) collision
C) polyinheritance
D) dynamic method binding
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
32
When you show abstract classes and methods in class diagrams, their names appear in ____.

A) bold
B) all caps
C) italics
D) blue
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
33
The Object class equals() method returns a(n) ____ value indicating whether the objects are equal.

A) int
B) equals
C) null
D) boolean
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
34
When a class both extends and implements , by convention the ____ clause follows the keyword  extends  in the class header.

A) extends
B) new
C) implements
D) if
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
35
If you do not specify a package for a class, it is placed in an unnamed ____ package.

A) system
B) language
C) default
D) general
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
36
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 ____.

A) address
B) value
C) hash code
D) number of characters
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
37
Which of the following is NOT true regarding abstract methods?

A) Abstract methods must be implemented in child classes.
B) Abstract methods have no body.
C) Abstract methods use the abstract keyword in declarations.
D) Abstract methods are inherited by their children.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
38
In other programming languages, such as C++, abstract classes are known as ____ classes.

A) anonymous
B) pseudo
C) simulated
D) virtual
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
39
Java's Object class contains a public method named ____ that returns an integer representing the hash code.

A) length()
B) hashCode()
C) hcode()
D) toString()
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
40
In the Java programming language, a package or class library is often delivered to users as a(n) ____ file.

A) JAR
B) interface
C) .java
D) class
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
41
What is the toString() method used for and how is it used?
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
42
A functional interface ____.

A) is the same as a package
B) can have multiple lambda expressions
C) contains just one abstract method
D) can only contain  effectively final variables
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
43
Match between columns
similar to a Zip file
dynamic method binding
similar to a Zip file
collision
similar to a Zip file
virtual classes
similar to a Zip file
multiple inheritance
similar to a Zip file
equals() method
similar to a Zip file
nonabstract method
similar to a Zip file
java.lang
similar to a Zip file
public , static , and final
similar to a Zip file
interface
similar to a Zip file
concrete class
similar to a Zip file
hash code
similar to a Zip file
anonymous inner class
similar to a Zip file
lambda expression
similar to a Zip file
JAR file
similar to a Zip file
functional interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
44
Match between columns
Data fields in an interface
dynamic method binding
Data fields in an interface
collision
Data fields in an interface
virtual classes
Data fields in an interface
multiple inheritance
Data fields in an interface
equals() method
Data fields in an interface
nonabstract method
Data fields in an interface
java.lang
Data fields in an interface
public , static , and final
Data fields in an interface
interface
Data fields in an interface
concrete class
Data fields in an interface
hash code
Data fields in an interface
anonymous inner class
Data fields in an interface
lambda expression
Data fields in an interface
JAR file
Data fields in an interface
functional interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
45
What is dynamic method binding and why is it used?
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
46
Match between columns
Creates an object that implements a functional interface
dynamic method binding
Creates an object that implements a functional interface
collision
Creates an object that implements a functional interface
virtual classes
Creates an object that implements a functional interface
multiple inheritance
Creates an object that implements a functional interface
equals() method
Creates an object that implements a functional interface
nonabstract method
Creates an object that implements a functional interface
java.lang
Creates an object that implements a functional interface
public , static , and final
Creates an object that implements a functional interface
interface
Creates an object that implements a functional interface
concrete class
Creates an object that implements a functional interface
hash code
Creates an object that implements a functional interface
anonymous inner class
Creates an object that implements a functional interface
lambda expression
Creates an object that implements a functional interface
JAR file
Creates an object that implements a functional interface
functional interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
47
Match between columns
Prohibited in Java
dynamic method binding
Prohibited in Java
collision
Prohibited in Java
virtual classes
Prohibited in Java
multiple inheritance
Prohibited in Java
equals() method
Prohibited in Java
nonabstract method
Prohibited in Java
java.lang
Prohibited in Java
public , static , and final
Prohibited in Java
interface
Prohibited in Java
concrete class
Prohibited in Java
hash code
Prohibited in Java
anonymous inner class
Prohibited in Java
lambda expression
Prohibited in Java
JAR file
Prohibited in Java
functional interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
48
Match between columns
Has no name and is defined inside another class
dynamic method binding
Has no name and is defined inside another class
collision
Has no name and is defined inside another class
virtual classes
Has no name and is defined inside another class
multiple inheritance
Has no name and is defined inside another class
equals() method
Has no name and is defined inside another class
nonabstract method
Has no name and is defined inside another class
java.lang
Has no name and is defined inside another class
public , static , and final
Has no name and is defined inside another class
interface
Has no name and is defined inside another class
concrete class
Has no name and is defined inside another class
hash code
Has no name and is defined inside another class
anonymous inner class
Has no name and is defined inside another class
lambda expression
Has no name and is defined inside another class
JAR file
Has no name and is defined inside another class
functional interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
49
Match between columns
The correct subclass method is attached to the application
dynamic method binding
The correct subclass method is attached to the application
collision
The correct subclass method is attached to the application
virtual classes
The correct subclass method is attached to the application
multiple inheritance
The correct subclass method is attached to the application
equals() method
The correct subclass method is attached to the application
nonabstract method
The correct subclass method is attached to the application
java.lang
The correct subclass method is attached to the application
public , static , and final
The correct subclass method is attached to the application
interface
The correct subclass method is attached to the application
concrete class
The correct subclass method is attached to the application
hash code
The correct subclass method is attached to the application
anonymous inner class
The correct subclass method is attached to the application
lambda expression
The correct subclass method is attached to the application
JAR file
The correct subclass method is attached to the application
functional interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
50
What is an abstract class? Give an example and explain how it works.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
51
Match between columns
A method that is inherited
dynamic method binding
A method that is inherited
collision
A method that is inherited
virtual classes
A method that is inherited
multiple inheritance
A method that is inherited
equals() method
A method that is inherited
nonabstract method
A method that is inherited
java.lang
A method that is inherited
public , static , and final
A method that is inherited
interface
A method that is inherited
concrete class
A method that is inherited
hash code
A method that is inherited
anonymous inner class
A method that is inherited
lambda expression
A method that is inherited
JAR file
A method that is inherited
functional interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
52
Match between columns
Contains just one abstract method
dynamic method binding
Contains just one abstract method
collision
Contains just one abstract method
virtual classes
Contains just one abstract method
multiple inheritance
Contains just one abstract method
equals() method
Contains just one abstract method
nonabstract method
Contains just one abstract method
java.lang
Contains just one abstract method
public , static , and final
Contains just one abstract method
interface
Contains just one abstract method
concrete class
Contains just one abstract method
hash code
Contains just one abstract method
anonymous inner class
Contains just one abstract method
lambda expression
Contains just one abstract method
JAR file
Contains just one abstract method
functional interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
53
When a superclass is abstract, you cannot instantiate objects of a superclass. How can you use a superclass abstract object?
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
54
Match between columns
A number that uniquely identifies an object
dynamic method binding
A number that uniquely identifies an object
collision
A number that uniquely identifies an object
virtual classes
A number that uniquely identifies an object
multiple inheritance
A number that uniquely identifies an object
equals() method
A number that uniquely identifies an object
nonabstract method
A number that uniquely identifies an object
java.lang
A number that uniquely identifies an object
public , static , and final
A number that uniquely identifies an object
interface
A number that uniquely identifies an object
concrete class
A number that uniquely identifies an object
hash code
A number that uniquely identifies an object
anonymous inner class
A number that uniquely identifies an object
lambda expression
A number that uniquely identifies an object
JAR file
A number that uniquely identifies an object
functional interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
55
Match between columns
An alternative to multiple inheritance available in Java
dynamic method binding
An alternative to multiple inheritance available in Java
collision
An alternative to multiple inheritance available in Java
virtual classes
An alternative to multiple inheritance available in Java
multiple inheritance
An alternative to multiple inheritance available in Java
equals() method
An alternative to multiple inheritance available in Java
nonabstract method
An alternative to multiple inheritance available in Java
java.lang
An alternative to multiple inheritance available in Java
public , static , and final
An alternative to multiple inheritance available in Java
interface
An alternative to multiple inheritance available in Java
concrete class
An alternative to multiple inheritance available in Java
hash code
An alternative to multiple inheritance available in Java
anonymous inner class
An alternative to multiple inheritance available in Java
lambda expression
An alternative to multiple inheritance available in Java
JAR file
An alternative to multiple inheritance available in Java
functional interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
56
Match between columns
A class-naming conflict
dynamic method binding
A class-naming conflict
collision
A class-naming conflict
virtual classes
A class-naming conflict
multiple inheritance
A class-naming conflict
equals() method
A class-naming conflict
nonabstract method
A class-naming conflict
java.lang
A class-naming conflict
public , static , and final
A class-naming conflict
interface
A class-naming conflict
concrete class
A class-naming conflict
hash code
A class-naming conflict
anonymous inner class
A class-naming conflict
lambda expression
A class-naming conflict
JAR file
A class-naming conflict
functional interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
57
Match between columns
Considers two objects of the same class to be equal only if they have the same hash code
dynamic method binding
Considers two objects of the same class to be equal only if they have the same hash code
collision
Considers two objects of the same class to be equal only if they have the same hash code
virtual classes
Considers two objects of the same class to be equal only if they have the same hash code
multiple inheritance
Considers two objects of the same class to be equal only if they have the same hash code
equals() method
Considers two objects of the same class to be equal only if they have the same hash code
nonabstract method
Considers two objects of the same class to be equal only if they have the same hash code
java.lang
Considers two objects of the same class to be equal only if they have the same hash code
public , static , and final
Considers two objects of the same class to be equal only if they have the same hash code
interface
Considers two objects of the same class to be equal only if they have the same hash code
concrete class
Considers two objects of the same class to be equal only if they have the same hash code
hash code
Considers two objects of the same class to be equal only if they have the same hash code
anonymous inner class
Considers two objects of the same class to be equal only if they have the same hash code
lambda expression
Considers two objects of the same class to be equal only if they have the same hash code
JAR file
Considers two objects of the same class to be equal only if they have the same hash code
functional interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
58
Match between columns
Contains the Object class
dynamic method binding
Contains the Object class
collision
Contains the Object class
virtual classes
Contains the Object class
multiple inheritance
Contains the Object class
equals() method
Contains the Object class
nonabstract method
Contains the Object class
java.lang
Contains the Object class
public , static , and final
Contains the Object class
interface
Contains the Object class
concrete class
Contains the Object class
hash code
Contains the Object class
anonymous inner class
Contains the Object class
lambda expression
Contains the Object class
JAR file
Contains the Object class
functional interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
59
Match between columns
Allows object instantiation
dynamic method binding
Allows object instantiation
collision
Allows object instantiation
virtual classes
Allows object instantiation
multiple inheritance
Allows object instantiation
equals() method
Allows object instantiation
nonabstract method
Allows object instantiation
java.lang
Allows object instantiation
public , static , and final
Allows object instantiation
interface
Allows object instantiation
concrete class
Allows object instantiation
hash code
Allows object instantiation
anonymous inner class
Allows object instantiation
lambda expression
Allows object instantiation
JAR file
Allows object instantiation
functional interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
60
Match between columns
The name given to abstract classes in other programming languages, such as C++
dynamic method binding
The name given to abstract classes in other programming languages, such as C++
collision
The name given to abstract classes in other programming languages, such as C++
virtual classes
The name given to abstract classes in other programming languages, such as C++
multiple inheritance
The name given to abstract classes in other programming languages, such as C++
equals() method
The name given to abstract classes in other programming languages, such as C++
nonabstract method
The name given to abstract classes in other programming languages, such as C++
java.lang
The name given to abstract classes in other programming languages, such as C++
public , static , and final
The name given to abstract classes in other programming languages, such as C++
interface
The name given to abstract classes in other programming languages, such as C++
concrete class
The name given to abstract classes in other programming languages, such as C++
hash code
The name given to abstract classes in other programming languages, such as C++
anonymous inner class
The name given to abstract classes in other programming languages, such as C++
lambda expression
The name given to abstract classes in other programming languages, such as C++
JAR file
The name given to abstract classes in other programming languages, such as C++
functional interface
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
61
  The shaded header of the talkingAnimal() method accepts any type of Animal argument. Explain how this is possible. The shaded header of the talkingAnimal() method accepts any type of Animal argument. Explain how this is possible.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
62
Compare and contrast abstract classes and interfaces.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
63
Why do many programmers consider multiple inheritance to be a difficult concept?
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
64
How is the Object class equals() method implemented?
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
65
    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.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
66
Describe the two method types programmers of an abstract class can include.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
67
public class Animal
{
}
public class Animal extends Object
{
}
The two class declarations above have identical outcomes. Explains why this is the case.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
68
    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.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
69
Give an example of how you can create an interface to have a class implement behavior from more than one parent.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
70
When you create classes for others to use, why would you not want to provide the users with your source code in the files with .java extensions?
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
71
  The AnimalReference application shown above contains a generic Animal reference variable into which you can assign concrete Animal objects. Explain how this example uses polymorphism and why it is important. The AnimalReference application shown above contains a generic Animal reference variable into which you can assign concrete Animal objects. Explain how this example uses polymorphism and why it is important.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
72
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?
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
73
When you create a useful, extendable superclass, you and other future programmers gain what advantages?
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
74
  An array can be created to reserve space for references to objects. Using the code above, explain how an array of superclass references can hold subclass references. An array can be created to reserve space for references to objects. Using the code above, explain how an array of superclass references can hold subclass references.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
75
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.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
76
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.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
77
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.
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
78
What are the advantages to creating a useful, extendable superclass?
Unlock Deck
Unlock for access to all 78 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 78 flashcards in this deck.