Tuesday, September 16, 2014

OCJP practice question #27

4:09 PM



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 .

0 comments :

Post a Comment

 

© 2014 DieHardTechy . All rights resevered. Designed by Diehardtechy