Menu
Question Index
...

What will be the output of following program?

interface A {

    void print1();

    void print2();
}

interface B extends A {

    void print3();
}

class Example implements B {

    public void print3() {
        System.out.println("print3");
    }

    public void print1() {
        System.out.println("print1");
    }

    public void print2() {
        System.out.println("print2");
    }
}

public class Extend {

    public static void main(String args[]) {
        Example e = new Example();
        e.print1();
        e.print2();
        e.print3();
    }
}


print1
print2
print3
print3
print1
print2
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Extending Interface In Java (extends)

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App