Menu
Question Index
...

What will be the output of the following program?

public class Revolution2020 {
    public static void main(String[] args) {
        Love love = new Love();
        love.aarti();
        Ambition gopal = new Corruption();
        Ambition raghav = new Ambition() {
            public String goal() {
                return "Pen Is Powerful ";
            }
            public void aarti() {
                System.out.print("Respect ");
            }
        };
        gopal.aarti(); gopal.goal();
        raghav.aarti(); raghav.goal();
        System.out.print(((Corruption) gopal).shukla());
    }
}
class Love {
    void aarti() { System.out.print("Beautiful ");    }
}
interface Ambition {
    String goal();
    void aarti();
}
class Corruption extends Love implements Ambition {
    int shukla() throws Exception { return 2020; }
    public String goal() { return "Get Rich "; }
    public void aarti() { System.out.print("Confused "); }
}


Beautiful Confused Get Rich Respect 2020
Beautiful Confused Get Rich Respect Pen Is Powerful 2020
Beautiful Confused Respect 2020
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Future Task Java Program Using Interfaces

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App