It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Error in Inquisition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Error in Inquisition" Watch "Error in Inquisition" New topic

Error in Inquisition

Cyril Boulm�

Joined: May 15, 2008
Posts: 11

I have tried the test by the Muppeteer in the software Inquisition,
and in question 28 :

Answer :
A/ 0
B/ some garbage
C/ 3
D/ Compilations failed

And it says correct answer is D with no explanation, but I tried it and answer is null!!
Is it an error or something I don't understand?

And in question 27

Consider these 4 statements:

Boolean b = Boolean.parseBoolean("true");
Boolean c = Boolean.valueOf("true");
Float f = Float.valueOf("1011",2);
Every wrapper has a public void toString(); method
How many compilable or true (in case of 4) statements do you see ?


Correct answer is C/2 and explanation is :
The first 2 are true. Via autoboxing 1) goes into the variable. The valueOf returns a Boolean object anyhow. A little trick to remember the return type is: if you hear the primitive in it (pareInt, pareShort, intValue, shortValue...) then it returns a primitive, else an Object

But for me ligne 4 is true too, because every object have a toString() method...
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

but does every object have a

public void toString();


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Daniel Del Moral
Ranch Hand

Joined: May 24, 2008
Posts: 32
Regarding question No. 27:

Every classes hast a public String toString() method from the Object class, hence is impossible that any object can implement a void toString() method because it doesn't override coreectly the toString method (bad return type)

Cyril Boulm�

Joined: May 15, 2008
Posts: 11
Ok thanks for question 27, I have not seen the void

And for question 28? Do you have an explanation?
Stevi Deter
Ranch Hand

Joined: Mar 22, 2008
Posts: 265


Question 28 (which is 14 when I set the test to go in order) looks fine to me and compiles in Java 5 and Java 6. As you found, it prints "null" because the zeroth element is null.

I note no explanation is included for the answer; perhaps you should check back with the test writer and ask him to verify his answer.

It's fine to assign an array of Integers to a Number array reference.

There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James
Matt Russell
Ranch Hand

Joined: Aug 15, 2006
Posts: 165
Oik, yeah, question "28" is clearly broken -- thanks for the bug report. It'll be fixed next time Inquisition is released.

Inquisition: open-source mock exam simulator for SCJP and SCWCD
Stevi Deter
Ranch Hand

Joined: Mar 22, 2008
Posts: 265

Hi, Matt,
Thanks for doing good work!
Deepak Chopra
Ranch Hand

Joined: Jul 23, 2007
Posts: 433

I give you the explanation why Q28 is giving you null as result.
if you see the Integer hirerachy, it come out to be following:

Object --> Number --> Integer

In array it is perfectly legal to declare:

ParentClass pc = new ChildClas[...];

Number na = new Integer[5];

This will declare an array that can hold 5 Integer Object and assign it to na.

Remember the array rule :
"Whenever an Array is declared all its element are initialized with default values"

so it your case, Default value for an Integer Object is null.
so you get na[0] == null

Thanks and Regards,
SCJP 1.5 (90%), SCWCD 1.5 (85%), The Jovial Java, java.util.concurrent tutorial
Consider Paul's rocket mass heater.
subject: Error in Inquisition
It's not a secret anymore!