Welcome Guest | Sign in | Register
Variables and Loops - Discussion Page For Q.2971 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Variables and Loops > Questions and Answers

Q: What is the output for the below code ?

public class A {
static{System.out.println("static");}
{ System.out.println("block");}
public A(){
System.out.println("A");
}
public static void main(String[] args){
A a = new A();
}}
A. A block static B. static block A
C. static A D. A

Answer and Explanation

Answer:static block A

Explanation:
First execute static block, then statement block then constructor.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.