Meaningless Drivel is fun!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes local variable! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "local variable!" Watch "local variable!" New topic

local variable!

Sridhar Srinivasan
Ranch Hand

Joined: Nov 07, 2003
Posts: 117
For the following, I gave the asnwer 2) but the answer given is 4)
Which option most fully describes will happen when you attempt to compile and run the following code
public class MyAr{
public static void main(String argv[])
MyAr m = new MyAr();
public void amethod(){
static int i;
1) Compilation and output of the value 0
2) Compile time error because i has not been initialized
3) Compilation and output of null
4) Compile time error
Canm anybody explain pl!

Yosi Hendarsjah
Ranch Hand

Joined: Oct 02, 2003
Posts: 166
Local variable can't be static.
Vineela Devi
Ranch Hand

Joined: Dec 20, 2003
Posts: 191
Hi Sridhar,
yeah, the answer is 4 coz the only modifier tht can be applied to local variables is "final".
Sridhar Srinivasan
Ranch Hand

Joined: Nov 07, 2003
Posts: 117
Oh!ok.Thanks a lot!
I agree. Here's the link:
subject: local variable!
jQuery in Action, 3rd edition