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

 
 

SCJP Module-1 Question-7
Posted on: July 7, 2010 at 12:00 AM
Advertisement
The program given below shows the feature of static block and their execution time in program and is very helpful for the SCJP examinations

Given a sample code:

1 abstract class Ball {
2 static {
3 int value = 10;
4 System.out.println("value = " + value);
}}

5 class Football extends Ball {
}

6 public class Sample2 {
7 public static void main(String args[]) {
8 new Football();
}}

What will be the result?

(1) Compilation succeeds but cause runtime error
(2) Compilation succeeds and give output 10
(3) Compilation fails because of an error at line 5
(4) Compilation fails because of line no 8

Answer

(2)

Explanations

This program execute with printing the output 10 on console.

Advertisement

Related Tags for SCJP Module-1 Question-7:


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