Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Hello-- Question on Return types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Hello-- Question on Return types" Watch "Hello-- Question on Return types" New topic
Author

Hello-- Question on Return types

Eric Warner
Greenhorn

Joined: Nov 14, 2004
Posts: 3
Howdy yall,

This is my first post and I would like to say that while lurking here for a while now, I am very impressed with the community and the support provided here. HUGE thanks to all that is making this possible. Also, thank you Kathy and Bert for all your books, interactive and interesting should be required whenever Comp Sci is the subject.

My question is from the K&B book page 344-345 #19

Question: which of the following code fragment inserted in "insert code here" will not compile?

Answer D & F
Explanation F returns an primitive, not an object, D is a reference to a char primitive

Why not also C & E ?

Thanks for any responses.

( tags added)
[ November 14, 2004: Message edited by: Barry Gaunt ]
Toms Liepins
Greenhorn

Joined: Nov 02, 2004
Posts: 21
Hi,
Arrays are actually Objects in Java. In fact, you can even do this:

The code above will make compiler happy. That's the case for C. As for E, here you have a multidimensional array (array of arrays). Hence, c[1] is a reference to another array. Note that you can't return c[1][0], as this would return a primitive.

I would suggest to re-read a chapter on Java fundamentals (arrays), I'm sure K&B book has some decent info on this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hello-- Question on Return types
 
Similar Threads
Question on Method return type
A doubt in overriding
Doubt related to Generics Question
Clrify results from SCJP mock exam site
Copying Integer to a file