Java Quiz 8: Abstract
False
A class that is declared final can be subclassed [T/F]
abstract superclasses
Abstract classes are used only as superclasses in inheritance hierarchies and are referred to as ___________________
False
Abstract classes can be instantiated [T/F]
False
Abstract methods, like default methods, include an implementation [T/F]
False
An abstract class must include abstract methods [T/F]
True
Classes can be declared as final [T/F]
abstract classes
Classes that cannot have objects created from them are called ___________________
True
Using the final keyword in a method declaration to indicate that the method cannot be overridden by subclasses [T/F]
concrete class
What is a subclass of an abstract superclass called that declares the missing pieces of the abstract class and can be instantiated?
False
When an abstract class is extended as a subclass, all abstract methods MUST implement the the abstract methods. [T/F]
- Want to take advantage of multiple inheritance of type - Want to specify the behavior of a particular data type, but not concerned about who implements its behavior - Expect that unrelated classes would implement the interface
When deciding between an abstract class and an interface, what applies when selecting an interface?
- Want to share code among several closely related classes - Want to declare non-static or non-final fields. - Expect that classes that extend the abstract class have many common methods or fields, or require access modifiers other than public (such as protected and private) - This enables you to define methods that can access and modify the state of the object to which they belong
When deciding between an abstract class versus an interface, if selecting an abstract class, what applies?
- To provide an appropriate superclass from which other classes can inherit - To share a common design
Why do developers create abstract classes? Select all that apply. - To create a unique class design - To provide an appropriate superclass from which other classes can inherit - To share a common design - to avoid using superclasses