Interfaces Flashcards
To define (declare) an interface class we use the keyword?
Interface
interfaces imposed at ? (Compile or runtime)
compile time
if a class implements an interface, all methods must be ?
overridden
A class can implement … number of interfaces?
many
a class can extend how many classes ?
at most one
interfaces can be in form of ?
fields or methods
data members of interface are
public static final
all methods of interface are
public abstract
interface is implemented using the keyword
implements
does an interface need a constructor? why?
no, because it can’t be instantiated
can interfaces inherit each other? how?
yes, by using extends
java supports multiple inheritance in form of?
in form of interfaces
all methods in an interface must be overridden, unless?
they are declared abstract
if a superclass implements an interface, all subclasses?
also implement it
common interfaces in java?
- comparable (compareTo())
- comparator (compare(), equals())
- serializable
- cloneable
compareTo return values are…
-ve, 0 , +ve
while compareTo return value means equals
0
which (abstract or interface) can have abstract and non abstract methods?
abstract class
which (abstract or interface) can have static, non static, final and non final variables?
abstract
which (abstract or interface) provides implementation of interface ?
abstract
which (abstract or interface) only extends interface classes?
interfaces
abstract classes are inherited using keyword?
extends
interface are inherited using the keyword?
implements
interface classes members can have modifiers of
public only