Week 4 - interfaces Flashcards

1
Q

Why use interfaces?

A

Java doesn’t support multiple inheritance so you can’t extend from 2 classes but you can extend from a single class and implement interfaces.

You can implement multiple interfaces

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

What does the Comparable interface do?

A

Allows you to compare objects it sort them in order

Any class which implements the comparable interface must code a method called compareTo()

Objects that implement this interface can be sorted using Arrays.sort()

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

An interface describes…

A

A set of method signatures that must be implemented.

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

A class that implements an interface must implement all the public methods declared in the interface. T or F?

A

True

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