Menu
Question Index
...

What will be the output of the following program?

class OutPut
{
    public static void main(String[] args)
    {
        PrintB c = new PrintB();

        System.out.println("printA = " + c.printA);

        System.out.println("printB = " + c.printB);
    }
}

class PrintA
{
    int printA = 5;
}

class PrintB extends PrintA
{
    printA = 10;
    int printB = 5;
}


printA = 10
printB = 5
printA = 5
printB = 5
Compilation Error
Runtime Error

Doubts

Problems

Topic: Assigning Sub Class Object To Super Class Reference 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