Welcome Guest | Sign in | Register
Static Concept - Discussion Page For Q.2935 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Static Concept > Questions and Answers

Exercise:

Section 1

Q: class A{
Int I;
Static{
A a=new A();
System.out.println(a.i);
}
}
A. compile time error B. compile time error
C. runtime error D. no output

Answer and Explanation

Answer:compile time error

Explanation:
JVM will execute SIB first , it will display default value of i. then JVM will come to know that there is no main method so it will throw an exception.so ans b) is correct.

Comment on this Question

Name:

Loading...




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