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
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()
3
Q
An interface describes…
A
A set of method signatures that must be implemented.
4
Q
A class that implements an interface must implement all the public methods declared in the interface. T or F?
A
True