If you're looking for an introductory text, you might try The Java Tutorial.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Sidd Kulk
Ranch Hand
Joined: Feb 20, 2007
Posts: 152
posted
0
For IS-A and HAS-A relation ship, say, when you quote 'Car IS-A Vehicle', it means that Car is a type of vehicle(in java terms, its a sub class of vehicle, or it extends vehicle), while when you say 'Car HAS-A Engine', it means that the class Car has a reference to an instance of class Engine. There is no direct relation between these classes. Hence, one can call a method on Car object to start the engine, and in turn, the car object would internally use the reference to Engine object to start the Car. This way the user doesn't have to worry about creating an instance of Engine, because Car HAS-A Engine.
Also, there might be other type of Vehicles which would need this Engine class reference. This way it avoids redundancy. That's OOP!!!
Sid
Alan Smithee
Greenhorn
Joined: Mar 21, 2006
Posts: 23
posted
0
2) How do you force garbage collection in Java ?
As mentioned above, you can't.
That being said...
Every object in Java inherits the finalize() method from java.lang.Object This is the method that is called by the garbage collector when no reference variables to the object exist. However, it really isn't an order to clean the object up. It's more of a suggestion. By design, there is nothing you can do that will 100% clean unreferenced objects up.
I hope that helps.
Durga Krishna
Greenhorn
Joined: Apr 05, 2007
Posts: 28
posted
0
How do you force garbage collection in Java ? We can force the garbage collection in java by calling the method System.gc().But there is no gaurentee that the object will be garbage collected.Because,if the heap is full with more than 80% then only garbage collector comes into picture.