Home Tutorial Java Scjp Part1 SCJP Module-1 Question-11

 
 

SCJP Module-1 Question-11
Posted on: July 7, 2010 at 12:00 AM
This program helps in understanding of inheritance in core Java and helpful for SCJP examination

Given a sample code:

1 class Test {
2 void printTest() {
3 System.out.println("superclass");
}}

4 class Sample1 extends Test {
5 Sample1() {
6 super.printTest();
}

7 public static void main(String args[]) {
8 new Sample1();
}}

What will be the result of above code ?

(1) Compilation fails because of an error on line 6
(2) Compilation fails because of an error on line 8
(3) Compilation fails because of an error on line 3
(4) Compile and run successfully with no error

Answer

(4)

Explanation:

It has no issue with the code. It will display the output on console.

Related Tags for SCJP Module-1 Question-11:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.