Welcome Guest | Sign in | Register
Static Concept - Discussion Page For Q.2932 | 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{

Static{
Main(null);}
Public static void main(String args[]){
System.out.println(“main”);}
}
A. compile time error B. runtime error
C. main main  D. exception

Answer and Explanation

Answer:main main 

Explanation:
Explanation: here we have declared SIB(static initialization block), JVM always executes SIB first before the main() method , then it executes main() method, here from SIB they are calling main() method by passing null as parameter so because of calling main() in SIB it displays “main” , then JVM executes main() method so again “main” will be displayed . so ans c) is correct.

Comment on this Question

Name:

Loading...




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