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

 
 

Share on Google+Share on Google+
SCJP Module-1 Question-11
Posted on: July 7, 2010 at 12:00 AM
Advertisement
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.

Advertisement

Related Tags for SCJP Module-1 Question-11:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 7, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com