wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes jqplus question: please help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "jqplus question: please help" Watch "jqplus question: please help" New topic
Author

jqplus question: please help

mark stone
Ranch Hand

Joined: Dec 18, 2001
Posts: 417
what is the output ? how is the parameter that generates an exception being passed as an argument in a method ???
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; }
}
Tarik Makota
Greenhorn

Joined: Jan 29, 2002
Posts: 23
the return value of oops is sent!!!
first i2=2 is executed and then function oops is called. Return value of oops will be used but it throws exception so you bail out.
 
 
subject: jqplus question: please help
 
Similar Threads
static problem
problem with oops method::
Declarations and access control
ARRAY doubt
Dan's Exam Array Doubt