Menu
Topics Index
...
`

Override methods different access


If you need explanation Read this topic

If you need Answer Take test on this topic

Override methods different access
What will be the output of the following program? Assume that all the classes belong to the same package.
class CURD {

    public static void main(String[] args) {
        new C().create();
        new D().update();
        new R().read();
        new D().delete();
    }
}

class C {
    public void create() { System.out.print("c"); }
}

class U {
    private void update() { System.out.print("u"); }
}

class R extends C {
    public void create() { System.out.print("C"); }
    protected void read() { System.out.print("R"); }
}

class D extends U {
    void update() { System.out.print("U"); }
    void delete() { System.out.print("D"); }
}

A. cURD
B. cuRD
C. CURD
D. Compilation Error
Topic: Method Overriding 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.

A is the answer.if they belogn to same packages.

Posted by Shabaaz Shaikz    2014-04-16 08:41:04


Ans is A as objects are created to all classes in CURD class and accessed all other classes and functions and prints cRUD

Posted by Bharath Yelchuri    2014-04-16 08:47:11


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

Posted by Merit Campus    2014-04-17 04:23:12


© meritcampus 2019

All Rights Reserved.

Open In App