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

Home > Java Programming > Flow Control > Questions and Answers

Q: class A{
Public static void main(String args[]){
System.out.println(“ main method starts ”);
test();
test();
test();
System.out.println(“ main method ends”);
}
Public static void test(){
System.out.println(“test”);
}
}
A. main method starts
test
test
test
main method ends
B. compile time error
C. run time error D. main method starts
main method ends
test
test
test

Answer and Explanation

Answer:main method starts
test
test
test
main method ends

Explanation:
here the code which we have in main method will execute, and test() method we are calling three times from main so test() method will execute three times. To call test() method no need to create an object because test() method is declared as static ,so memory will be allocated automatically. You can call directly.

Comment on this Question

Name:

Loading...




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