Welcome Guest | Sign in | Register
Static Concept - Discussion Page For Q.2929 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Static Concept > Questions and Answers

Exercise:

Section 1

Q: class A{

Static int i=10;
Static int j=I;
Public static void main(String args[]){
System.out.println(i);
System.out.println(j);
}
}
A. compile time error B. run time error

C. 10 10 D. no output

Answer and Explanation

Answer:10 10

Explanation:
Here I and j are static global variable ,these static variables are accessed inside a main() method, as these are static variable no need to create an object we can access directly because for static variables memory will be allocated automatically. So the value of I and j will displayed inside main() method.

Comment on this Question

Name:

Loading...




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