What will be the output of the following program?
class A {
    public void display() {
        System.out.print("One");
    }
}

class B extends A {
    @Override
    public void display() {
        super.display();
        System.out.print("Two");
    }
}

public class C {
    public static void main(String args[]) {
        B screen = new B();
        screen.display();
    }
}

Q:

Let’s say there are three classes: Laptop, MacBook and ThinkPad. What are the likely relationships between these classes?

Q:

Which of the following is true if a class Shape has a subclass Circle?

Q:

A subclass can inherit both instance variables and methods.

Q:

Which of the following is the correct syntax for defining a new class A based on the superclass B?

Q:

What will be the output of the following program? class A { public void display() { System.out.print(“One”); } } class B extends A { @Override public void display() { System.out.print(“Two”); } } public class C { public static void main(String args[]) { B screen = new B(); screen.display(); } }

Q:

What will be the output of the following program? class A { public void display() { System.out.print(“One”); } } class B extends A { @Override public void display() { super.display(); System.out.print(“Two”); } } public class C { public static void main(String args[]) { B screen = new B(); screen.display(); } }

Q:

What’s the usage of the java keyword ‘super’?

Q:

What restriction is there on using the super reference in a constructor?

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments