Given: interface Doable {
public void doSomething (String s);
}
Which two class definitions compile?
A. public abstract class Task implements Doable {
public void doSomethingElse(String s) { }
}
B. public abstract class Work implements Doable {
public abstract void doSomething(String s) { }
public void doYourThing(Boolean b) { }
}
C. public class Job implements Doable {
public void doSomething(Integer i) { }
}
D. public class Action implements Doable {
public void doSomething(Integer i) { }
public String doThis(Integer j) { }
}
E. public class Do implements Doable {
public void doSomething(Integer i) { }
public void doSomething(String s) { }
public void doThat (String s) { }
}
B,E
B is incorrect as abstract method cannot have a body.
A and E
Just E : Remember doSomethingElse is not the same as doSomething , so A is wrong!
Sorry , A is right too … although the Task class does not implement the doSomething method of the Doable interface, the Task class is an abstract class, thus allowing unimplemented methods.
A,E
A, E
A,E is right