Week 6 part 3 Flashcards

1
Q

Do abstract methods have a body?

A

No. There are also no braces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does a semicolon indicate in an abstract method?

A

That the declaration is complete

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Method = abstract, therefore class header must say

A

abstract

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Can it ever be useful to declare classes for which you never intend to create objects?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are abstract classes sometimes called? Why?

A

Abstract super classes. Since they’re used only as sueprclasses in inheritance hierarchies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

T/F - An abstract class provides a superclass from which other classes can inherit a common design

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Concrete classes are what?

A

Classes that can instantiate objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Concrete classes provide _____________ of every method they declare

A

implementations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

T/F - While you can’t instantiate objects of abstract super classes, you can use them to declare variables

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Variables from abstract super classes can hold references to objects of any concrete class, derived from those abstract super classes

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

T/F - Can use abstract superclass names to invoke
static methods declared in those abstract
super classes.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What happens if you try to instantiate an object of an abstract class?

A

Compilation error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What will happen if a class is NOT
declared abstract, and declares
an abstract method or inherits an
abstract method without providing
implementation?

A

Compilation error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Protected class members are public only

A

inside of a package, they’re private outside of the package.

The exception is they are visible via inheritance, even when inheritance is external.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Constructors of an abstract class can be made public, but should be made protected, why?

A

Because constructors are designed to return a new instance of a class. You don’t want new instances of abstract classes being created.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

T/F - You can access the constructor of an abstract class using the “super” keyword

A

True

17
Q

T/F - You can use protected constructors in the
inherited subclass of an abstract superclass ,
but you cannot use them to generate new
instances of the abstract superclass

A

True

18
Q

Is the use of protected a requirement of an abstract class?

A

No, just good practice