Welcome Guest | Sign in | Register
Flow Control - Discussion Page For Q.2785 | 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[]){
int i=10;
test(i);test(10); test(20);
}
Public static void test(int i){
System.out.println(i);
}
}
A. compile time error B. run time error
C. 10 10 20 D. no output

Answer and Explanation

Answer:10 10 20

Explanation:
here the code which we have in main method will execute, and test() method we are calling three times from main by passing I value and two constant values like 10,20 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.