Given the following interface definition, which definitions are valid?
interface Interface1{ void setValue (String s); String getValue (); }
Select 2 options
A. class A extends Interface1{ String s;// w ww. j ava 2 s. c o m void setValue (String val) { s = val; } String getValue () { return s; } } B. interface Interface2 extends Interface1{ void analyse (); } C. abstract class B implements Interface1{ int getValue (int i) { return 0; } } D. interface Interface3 implements Interface1{ void perform_work (); }
Correct Options are : B C
The *getValue(int i)* method of class B in option c, is different than the method defined in the interface because their parameters are different.
Therefore, this class does not actually implement the method of the interface and that is why it needs to be declared abstract.