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

Home > Java Programming > Flow Control > Questions and Answers

Q: class F{
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 public 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 public access specifier is not a mandatory for all the methods, its upto the developer to decide when to use public and all . BUT during runtime JVM will check the signature of main() method , but its wrong, because JVM will be searching for the method

Comment on this Question

Name:

Loading...




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