Welcome Guest | Sign in | Register
Flow Control - Discussion Page For Q.2770 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Flow Control > Questions and Answers

Q: class F
{
public void main(String args[])
{
System.out.println(“HI”);
}
}


A. compile time error
B. run time error
C. HI
D. no output

Answer and Explanation

Answer:run time error

Explanation:
here static keyword is removed from main() method signature, compiler will check whether main() method is declared properly or not , According to the compiler its correct, , because static keyword is not a mandatory for all the methods, its upto the developer to decide when to use static and all . BUT during run time JVM will check the signature of main() method , but its wrong, because JVM will be searching for the method which has public static void main(), so it will throw run time error. 

Comment on this Question

Name:

Loading...




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