File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes OCPJP Coding Exercises: Question 3c (Numeric Wrapper Classes) 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 "OCPJP Coding Exercises: Question 3c (Numeric Wrapper Classes)" Watch "OCPJP Coding Exercises: Question 3c (Numeric Wrapper Classes)" New topic
Author

OCPJP Coding Exercises: Question 3c (Numeric Wrapper Classes)

John Paterson
Ranch Hand

Joined: Mar 12, 2012
Posts: 125
Hi Folks,


Sharing my solution to the coding exercises for objective 3 from the book 'Practice Exams' by Bert Bates and Kathy Sierra.
This solution seems fine to me, do correct me if I am wrong or if there would be a better way of coding it.
Hope like minded souls would find this post useful. Thank you.



RESULT:
43


regards
John
Heena Agarwal
Ranch Hand

Joined: Dec 25, 2013
Posts: 261
    
    4
I can see only two numeric wrappers in your code. Where is the third one?
Rico Felix
Ranch Hand

Joined: Mar 08, 2014
Posts: 269
    
    4

Heena Agarwal wrote:I can see only two numeric wrappers in your code. Where is the third one?


The third wrapper class is created in the compute(Byte, Integer) method on line 22 after the evaluation of the expression completes in the statement -> Integer y = j+k;
The arguments j and k will be unboxed, their values added and the result will be boxed into an Integer object and assigned to the reference variable y.
Heena Agarwal
Ranch Hand

Joined: Dec 25, 2013
Posts: 261
    
    4
I think the question expects the third wrapper to be a different wrapper.
Heena Agarwal
Ranch Hand

Joined: Dec 25, 2013
Posts: 261
    
    4
Or may be not. It just says a third wrapper instance.

Anyway, I know those steps. But thanks.

One small correction - It's not the third wrapper 'class' that gets created. It's an instance.
 
GeeCON Prague 2014
 
subject: OCPJP Coding Exercises: Question 3c (Numeric Wrapper Classes)