Facebook

adsense

Saturday, 2 May 2015

QUESTION 13

What is displayed when the following is executed?

class Parent
{
    private void method1()
    {
        System.out.println("Parent's method1()");
    }
    public void method2()
    {
        System.out.println("Parent's method2()");
        method1();
    }
}
class Child extends Parent
{
    public void method1()
    {
        System.out.println("Child's method1()");        
    }
    public static void main(String args[])
    {
        Parent p = new Child();
        p.method2();
    }
}
--------------------------------------------------------------------------------------
A. Compile time error 
B. Run time error 
C. prints : Parent's method2()
          Parent's method1() 
D. prints : Parent's method2() 
          Parent's method1() Child's method1()

<PREVIOUS || Main Page || NEXT >
GIVE YOUR ANSWER IN THE COMMENT BELOW

No comments:

Post a Comment