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

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
FrodoBaggins
Posts: 14
Joined: Tue Jun 02, 2015 8:32 am
Contact:

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

Post 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?

admin
Site Admin
Posts: 10398
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

You very well may. We have seen candidates get more than 7 options, sometimes even 8!

Rinkesh
Posts: 35
Joined: Sat Nov 25, 2017 4:13 pm
Contact:

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

Post 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.

admin
Site Admin
Posts: 10398
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

1. What happened when you tried to compile it?
2. Did you read the explanation that is given with this option?

Rinkesh
Posts: 35
Joined: Sat Nov 25, 2017 4:13 pm
Contact:

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

Post 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.

admin
Site Admin
Posts: 10398
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

That's good. But try it with same variable name as well and see what happens.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 7 guests