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

Answer and Explanation

Answer:compile time error

Explanation:
here variable I is local variable , it is accessible only within the main() method , but in the above code they are trying to access from test() method ,so it will throw an compile time error.

Comment on this Question

Name:

Loading...




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