File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes mock question  Wrapper issue 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 "mock question  Wrapper issue" Watch "mock question  Wrapper issue" New topic

mock question Wrapper issue

Youssef Ghazal

Joined: May 27, 2007
Posts: 10

i try it one mock exam and i stopped in this question :

What will happen if you attempt to compile and run the following code?

1) 19 followed by 20
2) 19 followed by 11
3) Compile time error
4) 10 followed by 1

and i choose the second option ,and i confirmed my option with running the code and it showed "19 10"

but when i see them answer i was suprised they said a compile error will occurs

The wrapper classes cannot be used like primitives.

Depending on your compiler you will get an error that says someting like "Error: Can't convert java lang Integer". Wrapper classes have similar names to primitives but all start with upper case letters.

Thus in this case we have int as a primitive and Integer as a wrapper. The objectives do not specifically mention the wrapper classes but don't be surprised if they come up.

.i don't see why .
[ August 26, 2007: Message edited by: Youssef Ghazal ]
Ajay Divakaran

Joined: Jul 08, 2007
Posts: 22
i got the o/p as
19 11
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15082

Autoboxing (automatically converting primitive types to instances of wrapper classes) is a new feature of Java 5.

Was the mock exam you are doing for Java 1.4?

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Youssef Ghazal

Joined: May 27, 2007
Posts: 10
it's a java 4 version.
I agree. Here's the link:
subject: mock question Wrapper issue
It's not a secret anymore!