Welcome Guest | Sign in | Register
Static Concept - Discussion Page For Q.2930 | 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 J
{
Static
{
System.out.println(“first”);
}
Public static void main(String args[])
{
System.out.println(“main”);
}
}
A. first
main
B. main
first
C. compile time error D. runtime error

Answer and Explanation

Answer:first

main

Explanation:
here we have declared SIB(static initialization block), JVM always executes SIB first , then main() method , then it executes main() method, so ans a) is correct.

Comment on this Question

Name:

Loading...




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