Page 1 of 1

About Question enthuware.ocajp.i.v8.2.1025 :

Posted: Sat Jun 06, 2015 2:52 am
by FrodoBaggins
Why had this question got six options on it. I am not going to get six options to choose from in the exam am I?

Re: About Question enthuware.ocajp.i.v8.2.1025 :

Posted: Sat Jun 06, 2015 6:02 am
by admin
You very well may. We have seen candidates get more than 7 options, sometimes even 8!

Re: About Question enthuware.ocajp.i.v8.2.1025 :

Posted: Wed Dec 20, 2017 10:03 am
by Rinkesh

Code: Select all

try {
       s = new ServerSocket(3030); 
} 
catch(Exception t){ t.printStackTrace(); } 
catch(IOException e) { 
    s = new ServerSocket(4040);
}
catch(Throwable t){ t.printStackTrace();  }
I am seeing a code with difference exception reference variables(e and t) for the first time so the program will compile with them if the subclass exceptions are before superclass exception??

Thank you in advance.

Re: About Question enthuware.ocajp.i.v8.2.1025 :

Posted: Wed Dec 20, 2017 10:57 am
by admin
1. What happened when you tried to compile it?
2. Did you read the explanation that is given with this option?

Re: About Question enthuware.ocajp.i.v8.2.1025 :

Posted: Wed Dec 20, 2017 2:05 pm
by Rinkesh

Code: Select all

class Eh4 //try with multiple catch
{
public static void main(String args[])
{
try
{
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int r=a/b;
System.out.println("ans="+r);
}
catch(NumberFormatException g)
{
System.out.println("Wrong Data");
}
catch(ArrayIndexOutOfBoundsException s)
{
System.out.println("Missing Data");
}
catch(ArithmeticException r)
{
System.out.println("Invalid Operation");
}
catch(Exception o)
{
System.out.println("Other Error");
}
}}
I changed the reference variables of all the exceptions and it still works fine.So I think it doesn't matter.Thank you Paul for making me work instead of telling me the answer right way.This is making me a better programmer and I am understanding the Java Compiler and JVM better.

Re: About Question enthuware.ocajp.i.v8.2.1025 :

Posted: Thu Dec 21, 2017 3:22 am
by admin
That's good. But try it with same variable name as well and see what happens.