Tech Me More

To quench our thirst of sharing knowledge about our day to day experience & solution to techincal problems we face in our projects.

Advertise with us !
Send us an email at diehardtechy@gmail.com

Tuesday, September 16, 2014

OCJP practice question #27



What will be the output of following java program ?

class SomeClass
{
static int i ;

public SomeClass()
{
i = 1;
}

private static int increment(int i)
{
return ++i;
}

public static void main(String[] args)
{
System.out.print(i);
System.out.print(increment(i));
System.out.print(i);
}
}



Options

1. 000
2. 012
3. 010
4. compilation error

Answer:

Option 3 is the correct choice .

No comments: