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

Home > Java Programming > Flow Control > Questions and Answers

Q: class F{
Private static 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 private keyword is used in main() method signature, compiler will check whether main() method is declared properly or not , According to the compiler its correct, because private access specifier declaration is correct , its upto the developer to decide when to use public, private and all . BUT during runtime 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 runtime error. 

Comment on this Question

Name:

Loading...




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