Question ID :958005937570
The following class will print '2' when compiled and run.
class
Test {
public static int[ ] getArray() { return null; }
public static void main(
String[] args)
{
int index = 1;
try
{
getArray()[index=2]++; // Line 1
}
catch (Exception e){ } //empty catch
System.out.println("index = " + index);
}
}
Ans: True
PROBLEM: why is the index 2 and not 3 . I understand that this is a postfix operator ++ but still at the end the value fo index shd be 3 i think.
Morever, i have not come accross any method call
which has an array dimension like line 1
Thanks in advance
padmini