Correct answer is: C
The answer lies on the surface - you just have to be careful. An abstract class method must either be abstract or have an implementation! In this case, we need to fix the syntax error - make the method abstract.
Tested, answer is C.
To test:
abstract class Robot implements Speakable {
public void process(); // replace public void process(); with public abstract void process();
}
class Humanoid extends Robot {
public void speak(String s) {
System.out.println(s);
}
public void process() {
System.out.println("Helping... ");
}
}
interface Speakable {
public void speak(String s);
}
public class Test {
public static void main(String[] args) {
Robot r = new Humanoid();
r.process();
r.speak("Done");
}
}
The correct answer is letter C, you can answer by elimination:
A -> The humanoid class already overloads the 2 methods of its super class and the interface that implements its superclass, it wouldn't change anything to put abstract in the class definition
B -> I wouldn't change anything either, even switching to an abstract class, its methods are overloaded
D -> This is the most wrong one, a class cannot extend an interface, classes implement interfaces, the only type of object that can extend interfaces are the interfaces themselves.
upvoted 1 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
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.
dsms
5 months, 2 weeks agoakbiyik
1 year, 1 month agocarloswork
1 year, 3 months agoiSnover
1 year, 3 months ago