AbstractClasses Flashcards

1
Q

What is an abstract method?

A

Includes a definition but no implementation.

A method without a body must be declared abstract.

Class may also be abstract.

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

What is an interface?

A

Contains only abstract methods, no fields.

Static fields OK.

Define behavior, but not implement it.

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

How do you implement an interface?

A

Uses keyword implements instead of extends.

A concrete class that implements an
interface must provide an implementation of
all of the methods in the interface.
○ An abstract class does not need to.
● In Java, a class may only extend one other class, but may implement an unlimited number of interfaces

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