This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Mock Exam Errata and the fly likes problem from khalid's book 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 » Mock Exam Errata
Bookmark "problem from khalid Watch "problem from khalid New topic
Author

problem from khalid's book

smriti singla
Greenhorn

Joined: Nov 14, 2000
Posts: 18
hello
in problem 1.4 (review questions,chapter 1)in Khalid's book it is given that Thing is a class and how many objects and reference variables are created by the following code
Thing item, stuff;
item = new Object();
Thing entity = new Object();
According to me the answer should be no object is created and three reference variables are created as creating an object involves using the new operator togather with a call to constructor of the class(given on page 4 in book under topic "class instantiation") and 'Object()' is not a constructor of class Thing as constructor always has the same name as that of the class.But answers given in the book on page 623 shows that options b and f are true which shows that two objects and three reference variables are created.i could not understand this.please explain this if anybody knows.any help will be highly appreciated.
Thanks
Smriti Singla
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Smriti,
You are correct in assuming that the Compiler will most likely complain about assigning instance Object to instance Thing. I think this was corrected in the book errata ...
Correct problem:

Using the above corrected code, the results stated by Khalid are correct.
Regards,
Manfred.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem from khalid's book
 
Similar Threads
Question about no of objects & references
Objects and refrences
Mughal's mock exam erratum
Objects and References
question from khalid's book