Question: //Declare an interface called speaker public interface Speaker { //defined methods public void speak(); public void announce(String Str); } public class Professor implements Speaker {

//Declare an interface called speaker public interface Speaker { //defined methods public void speak(); public void announce(String Str); } public class Professor implements Speaker { public void speak() { System.out.println("Professor speaks about subject"); } public void announce(String str) { System.out.println("Professor delivers the lecture"+str); } } public class Politician implements Speaker { public void speak() { } public void announce(String str) { System.out.println("Politican announces the "+str); } } public class President implements Speaker { public void speak() { System.out.println("President speaks about Country"); } public void announce(String str) { System.out.println("President announces the"+str); } } //driver class public class Driver { public static void main(String args[]) { //instanting the professor ability=new Professor(); ability.speak(); //instantiating the politician ability=new Politician(); ability.speak(); //instantiating the President ability=new President(); ability.speak(); } }

what is wrong in the code?

it is not compliing

please correct and show the output the output should be

output

Professor speaks about subject

Politician speaks about politics

President speaks about Country

please show this in image that it is compliing

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!