Menu
Question Index
...

What will be the output of the following program?

class OutPut
{
    public static void main(String s[])
    {
        int i = 2;
        B b = new B();
        b.execute();
    }
}

class A
{
    A()
    {
        int i = 1;
    }
}

class B extends A
{
    void execute()
    {
        System.out.println("i = " + i);
    }
}


i = 2
i = 1
Compilation Error
Runtime Error

Doubts

Problems

Topic: Inheritance And Constructors In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App