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:
Post a Comment