Monday, November 21, 2011

Java Programme2

class MyExample{
public static void main(String[] args){
String v="-";
try{
calculate(args[0]);
v=v+"k";
}
finally{
System.out.println(s+="f");}
}
public static void calculate(String b)
{
int y=7/Integer.parseInt(a);
}
}

At the command line :

java MyExample
java MyExample 0

What would be the ouput of the above.

On both the invocations finally block will be executed. ArrayIndexOutOfBoundsException,ArithmeticException will be thrown respectively.

No comments:

Post a Comment