About Question enthuware.ocajp.i.v7.2.865 :

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

Moderator: admin

Post Reply
ETS User

About Question enthuware.ocajp.i.v7.2.865 :

Post by ETS User »

I was thrown by the fact that main() is declared as throwing an Exception, yet the Data class wasn't throwing any. I was expecting a compiler error as a result.

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

Re: About Question enthuware.ocajp.i.v7.2.865 :

Post by admin »

A method can be defined to throw any exception even though the code inside it does not throw that exception.
HTH,
Paul.

deepa.patre
Posts: 15
Joined: Thu Dec 13, 2012 9:44 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.865 :

Post by deepa.patre »

I just had a doubt with the answer.
how the output is 10Y 0Z ?
i got the point of 10Y but why it is 0Z instead of 10Z because the value of x is changed to 10 when the first object is called because objects are passed by reference...

Please advise!

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

Re: About Question enthuware.ocajp.i.v7.2.865 :

Post by admin »

There are two Data objects. The first one is created with int 10 and the second one is created with string "Z". Where do you see x being changed to 10 for the second Data object?

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests