Given: interface Doable { public void doSomething (String s); } Which two class definitions compile? (Choose two.)
A.
public 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 abstract 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) { } }
Answer is CE,
Option A implements doSomethingElse(String s) instead doSomething(String s).
Option C abstract method allowed not to implement functions methods
Answer C and E. A doesn't compile since method name is doSomethingElse and not doSomething. B isn't ok since doSomething is defined as abstract but provides implementation.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
varconite
Highly Voted 3 years, 7 months agovarconite
3 years, 7 months agoshivkumarx
Most Recent 3 months, 2 weeks agoasdfjhfgjuaDCV
4 months, 1 week agosteefaand
5 months, 1 week agoMahdiHamdii
1 year, 6 months agoWilsonKKerll
2 years, 4 months agoMudzingwa
2 years, 6 months agoSamriddji
2 years, 7 months agoSvetleto13
3 years, 2 months agoSamps
3 years, 10 months agoadnano1234
4 years, 6 months ago