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

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

Moderator: admin

Post Reply
prateeks
Posts: 3
Joined: Sun Jun 23, 2013 10:48 am
Contact:

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

Post by prateeks »

The last option states-
If (1) was a valid constructor 'int' would be promoted to long at the time of passing.
How can an int be promoted to long. int will be boxed to Integer, How can that Integer be converted to long then?

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

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

Post by admin »

In this case int will not be boxed into an Integer. It will be promoted to long because that is the type of the argument in //1. This is a rule of the language: http://docs.oracle.com/javase/specs/jls ... #jls-5.1.2

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

chronix
Posts: 5
Joined: Mon Jan 04, 2016 12:28 am
Contact:

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

Post by chronix »

Why trick testers with these kind of questions. Wouldn't it defeat the purpose of
measuring what the testers know? After answering many questions I almost selected
the wrong option here. Exhaustion and stress plays a lot when taking tests.

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

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

Post by admin »

You are right but unfortunately, the real exam does test a candidate on finer points of the Java language.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.

brianwcraig
Posts: 1
Joined: Tue Mar 06, 2018 10:14 am
Contact:

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

Post by brianwcraig »

I am looking at question v8.2.1098 and line 1 is stated as
public void TestClass(long pLong) { l1 = pLong ; } //(1)
"The declaration at (1) declares a method, not a constructor because it has a return value. The method happens to have the same name as the class, but that is ok."

void is now returned, so this is now a valid constructor, was the question text updated and not the answer or am I missing something ?

UPDATE (answered my own question):
"void" is the return value.
For it to be a valid constructor it would be stated: public TestClass(long pLong) { l1 = pLong ; } //(1)

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 46 guests