Originally posted by shailu kommineni:
What does it mean when you say java garbage collects any unused objects?
What is the difference betweeen creating an object on stack and creating them on heap? If performance is such a big issue, why not create the objects on stack itself( is stack a limited resource?)?
I have a class which extends another. If I create an object of the class B (extending A) do I have access to all the private methods of the class A?
If not how exactly "is" B A?
Originally posted by Ernest Friedman-Hill:
Hi,
Welcome to JavaRanch!
Because anything that some other class C can do to an A object, it can also do to a B object; for example, if C has a method twiddleA() which accepts an A as a parameter, you can pass a B when you call it, and everything works fine.
[ January 26, 2004: Message edited by: Ernest Friedman-Hill ]
Originally posted by shailu kommineni:
1. If C expects an object of A but you are passing an object of B. If in the method twidleA C is creating an object of A and on the instance of A calling some private methods of A, then can it do the same when you pass an object of B?
2. Also I pass B to twiddleA method of C which has a serveNoodles method. It will use a method of A say, cookNoodles which boils noodles without frying them but same method of B will fry them and then boils. C expects some behaviour but a different behaviour results when you pass a different ( subclass) object of A (B). Then how can you say that everything works fine?
3. What is the best book to study java if I want to know what exactly happens behind the scenes as well?
(I am really thrilled to receive response from an author!! Is your book on java? Then you will obviously say it is the best book? )
I once met a man from Nantucket. He had a tiny ad
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|