Menu
Topics Index
...
`

SuperClass2751


If you need explanation Read this topic

If you need Answer Take test on this topic

SuperClass2751
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();
    }
}

A. 20 30
B. 60
C. Some other output
D. Compilation Error or Runtime Error
Topic: Access Modifiers In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans is A.

Posted by Gopinath Manchikanti    2014-08-11 08:51:49


a

Posted by Zeg Abder    2014-08-11 08:53:00


ans a.values  20 ,30 pasd as argument
20 assigned to a
30 assigned to b
a and b gets printd

Posted by Maheshwari Natarajan    2014-08-11 09:34:59


Congratulations Maheshwari Natarajan. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-08-12 04:10:45


© meritcampus 2019

All Rights Reserved.

Open In App