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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started