Can anybody help analyze these questions?
I have been trying to figure it out,....by the way this is one
of the questions from jqplus
question ID :957921513300
What will be the output of the following program ?
class
Test {
static int i1, i2, i3;
public static void main(
String[] args)
{
try
{
test(i1 = 1, oops(i2=2), i3 = 3);
} catch (Exception e)
{
System.out.println(i1+" "+i2+" "+i3);
}
}
static int oops(int i) throws Exception
{
throw new Exception("oops");
}
static int test(int a, int b, int c) { return a + b + c; }
}
******************************************************
ANS 1,2, 0
******************************************************
Question ID :954959233442
What is the effect of compiling and running this class ?
public class TestClass
{
public static void main (String args [])
{
int sum = 0;
for (int i = 0, j = 10; sum > 20; ++i, --j) // 1
{
sum = sum+ i + j;
}
System.out.println("Sum = " + sum);
}
}
************************************************
why will print sum = 0
************************************************