Menu
Topics Index
...
`

SuperClass


If you need explanation Read this topic

If you need Answer Take test on this topic

SuperClass
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 a.by callin get data () methd values r printd

Posted by Maheshwari Natarajan    2014-07-01 08:52:28


A

Posted by Sanni Heruwala    2014-07-01 09:01:23


answr a
refernc objct is cretd fr class b.
by using dot operatr getdata() methd is acsd.
n vlues a b r printd

Posted by NagaRaj Nataraj    2014-07-01 09:13:14


A

Posted by Shri Nandhitha    2014-07-01 09:37:13


A

Posted by Rathod Ajay    2014-07-01 10:36:42


A

Posted by Abhijit Bhusare    2014-07-01 18:15:43


A

Posted by Abhijit Bhusare    2014-07-01 18:16:49


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-07-02 04:19:19


© meritcampus 2019

All Rights Reserved.

Open In App