Menu
Question Index
...

What will be the output of below program?

class A {
    public int a;
    protected int b;

    void getdata(int c, int d) {
        a = c;
        b = d;
        System.out.println(a + " " + b);
    }
}

class B extends A {
    public int mul;

    void multiplication() {
        mul = a * b;
    }
}

public class Inheritance {
    public static void main(String args[]) {
        B subobj = new B();
        subobj.getdata(20, 30);
        subobj.multiplication();
    }
}


20 30
60
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Access Modifiers 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