1. Home
  2. Computing & Technology
  3. Computer Certification

Question 28

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

            }

}

 

Compile time error
Run time error
prints : Parent's method2()

           Parent's method1()

prints : Parent's method2()

           Child's method1()


Back to beginning
| Next Question



Explore Computer Certification
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Computer Certification

©2009 About.com, a part of The New York Times Company.

All rights reserved.