Java OOP SHORT
ANSWER QUESTIONS INTERFACES
& POLYMORPHISM QUESTIONS
2-Consider
the following class header: public
class G implements H We know that G is a(n) ____________ and H is a(n) ____________. 3-An
interface is simply a list of _____________ headers without bodies (though
they can also contain variables that are constant). 4-True
or false. A class can implement
multiple interfaces. ___________
a)
Checkable
c = new Box(); b)
Box
b = new Checkable(); 7-Which
of the following states will make class Coco implement both interfaces
Comparable and Iterable? a)
public
class Coco implements Comparable implements Iterable b)
public
class Coco implements Comparable, Iterable c)
public
class Coco implements Comparable and Iterable d)
public
class Coco implements Comparable && Iterable 8-What
happens if a class tries to implement two interfaces that each have the same
method header in them? (Try it!) a)
An
error occurs. b)
It
works fine. c)
Java
gets confused. 9-Class
B implements interface A. Which of the
following is a permitted polymorphic reference in Java? a)
A
ref = new A(); b)
B
ref = new B(); c)
B
ref = new A(); d)
A
ref = new B();
11-We can use ___________________ on the line above a method header to
specify to Java that that method is part of the interface which the class is
implementing. 12-True or false. The use of
@Override is optional. 13-Find the error in the code below.
14-Find the
error in the code below.
15-Find the
error in the code below.
16-Find the
error in the code below.
SOLUTIONS Click here. |
|||||||
|