Week 6 part 3 Flashcards
Do abstract methods have a body?
No. There are also no braces
What does a semicolon indicate in an abstract method?
That the declaration is complete
Method = abstract, therefore class header must say
abstract
Can it ever be useful to declare classes for which you never intend to create objects?
Yes
What are abstract classes sometimes called? Why?
Abstract super classes. Since they’re used only as sueprclasses in inheritance hierarchies.
T/F - An abstract class provides a superclass from which other classes can inherit a common design
True
Concrete classes are what?
Classes that can instantiate objects
Concrete classes provide _____________ of every method they declare
implementations
T/F - While you can’t instantiate objects of abstract super classes, you can use them to declare variables
True
Variables from abstract super classes can hold references to objects of any concrete class, derived from those abstract super classes
True
T/F - Can use abstract superclass names to invoke
static methods declared in those abstract
super classes.
True
What happens if you try to instantiate an object of an abstract class?
Compilation error
What will happen if a class is NOT
declared abstract, and declares
an abstract method or inherits an
abstract method without providing
implementation?
Compilation error
Protected class members are public only
inside of a package, they’re private outside of the package.
The exception is they are visible via inheritance, even when inheritance is external.
Constructors of an abstract class can be made public, but should be made protected, why?
Because constructors are designed to return a new instance of a class. You don’t want new instances of abstract classes being created.