Page 1 of 1

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

Posted: Mon Jun 24, 2013 7:26 am
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?

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

Posted: Mon Jun 24, 2013 7:48 am
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.

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

Posted: Mon Jan 04, 2016 11:26 pm
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.

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

Posted: Tue Jan 05, 2016 12:37 am
by admin
You are right but unfortunately, the real exam does test a candidate on finer points of the Java language.
HTH,
Paul.

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

Posted: Thu Mar 08, 2018 8:48 am
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)