Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions

Question

List the commonly used activation functions.

Answered: 1 week ago