- Shopping Bag ( 0 items )
Ships from: fallbrook, CA
Usually ships in 1-2 business days
Ships from: Irving, TX
Usually ships in 1-2 business days
Ships from: Chatham, NJ
Usually ships in 1-2 business days
Get complete details on exam topics,including how to:
Objects are allocated from a garbage-collected heap. You cannot directly alter the memory in this heap. You can only get at the objects in this heap by using object refer-ences. Since Java manages the heap, and since you cannot manipulate object references, you must trust the Java Virtual Machine (JVM) to do what's right: free memory when it should, allocate the correct amount of memory when needed, and so on. But don't worry; the JVM is very good at its job—much better than any of us error-prone humans.
As another example, you might create an object, assign this object to an object reference, and then set this object reference to null. As soon as you lose the reference to the object, that object becomes a candidate for garbage collection.
Just because your program might lose a reference to an object does not mean that the JVM will reclaim that object's memory right away, or even at all. The JVM will only perform garbage collection if it needs more memory to continue executing. For almost all simple programs, including the ones you've seen so far, the JVM doesn't even come close to running out of memory.
CAUTION: The reason the garbage collector does not reclaim memory as soon as it is available is that garbage collection takes time. If the garbage collector were continuously expunging allocated memory that you could no longer access, it would seriously slow your program's execution. It is not guaranteed that the garbage collector will reclaim objects in a certain order. This allows the garbage collector to run as efficiently as possible.
Even though a new keyword exists, notice that you do not explicitly indicate how much memory to set aside. The JVM determines this for itself. The JVM determines the memory your object requires based on
They way you run the garbage collector is to perform two steps:
Runtime rt = Runtime.getRuntime(); rt.gc();
Exercise 5-2 asks you to work through an example of this.
However, you can get into the act of garbage collection. If you want to perform some task when your object is about to go away, you can override a method called finalize().
Java will invoke the finalize() method exactly once for every object in your program. finalize() is declared as protected, does not return a value, and throws a Throwable object.
Java invokes the finalize() method just before an object is about to be garbage collected. You might take advantage of this notification to clean up any resources that have been allocated outside this object. A classic example is a file that an object has opened that might still be open. The object can check to see if the file has been closed in finalize() and, if not, it will close the file....
|Pt. I||Studying for the Programmer's Exam||1|
|Ch. 1||Programmer Exam Roadmap||3|
|Ch. 2||Java Programming Fundamentals||17|
|Ch. 3||Java Keywords||31|
|Ch. 4||Java Building Blocks||43|
|Ch. 5||Memory and Garbage Collection||57|
|Ch. 6||Data Types and Values||73|
|Ch. 8||Control Flow||117|
|Ch. 11||Objects and Classes||167|
|Ch. 12||Packages, Inheritance, and Interfaces||207|
|Ch. 13||Passing Arguments to Programs||233|
|Ch. 16||Essential java.lang and java.util||301|
|Ch. 18||java.awt: Graphics and Components||357|
|Ch. 19||java.awt: Layout||393|
|Ch. 20||java.awt: Event Handling||409|
|Ch. 21||Sun Certified Programmer Practice Exam 1||429|
|Ch. 22||Sun Certified Programmer Practice Exam 2||459|
|Ch. 23||Sun Certified Programmer Practice Exam 3||483|
|Pt. II||Studying for the Developer's Exam||511|
|Ch. 24||Developer Exam Roadmap||513|
|Ch. 25||Developing with Java||523|
|Ch. 26||Accessing and Managing Databases||551|
|Ch. 27||Network Programming and Communication||577|
|Ch. 28||Designing Application Interfaces||623|
|Ch. 29||Sun Certified Developer Practice Programming Assignment||643|
|Ch. 30||Sun Certified Developer Practice Essay Exam||675|
|App. A: What's on the CD-ROM||683|
|App. B||The JDK||685|
Posted June 21, 2003
Don't bother reading the book, there are errors all over the place (begining with Ch 1). Guess if you don't have any knowledge of Java, you won't notice the errors! I wish I had read the book immediately after buying it. I read it couple of months after buying and so could not even return it for a refund.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted January 11, 2003
After reading several reviews, i was disappointed when i finished reading this book .... The book contained syntax errors and codes that doesn't even compile. I wondered if the author ever compiled his codes .... I just finished the java 1.4 certification exam and passed with the help of "THINKING IN JAVA" by Bruce Eckel. ... I advise you to find the topic for the certification exam and then go purchase Thinking in java and review each topic. The book shoud provide you with explicit information to help you pass the exam ... *******Dont bother buying ANY certification exam books ***** You might as well spend the money on THINKING IN JAVA, which provide you detailed information rather generalize shorten reviews on each topic as given by certification books ... A few days before the exam you should sit for an hour or two at Barnes and Noble and review the sample exams given by certification books, but be advised that the author's mock exams may contain syntax and even semantics errors.... Well hope this helps... and if your still worrying about certification exams.... just know that i COUNTER STRIKE the week before the exam and studied at most 3 hours and still passed the exam.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted May 3, 2002
I studied Java 2 from other books and bought this book so I could prepare for certification. This book is excellent for that purpose. The first 500 pages are about the programmer's exam. Each chapter is very comprehensive and in the end you can take practice tests about the whole area. This first part is what I use frequently to test my skills and knowledge.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted February 16, 2002
This is the best Java book I found! I read several others but this was the one that answered my questions and was usable. I highly recommend this book to anyone looking to certify. This book also makes a great reference -- I used it everyday!Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted November 26, 2001
Java 2 AllinOne Cert guide is well-organized and very accurate! I've used it to help me learn more about Java programming and I refer to it often... I'm also using the book to study for certification. I originnaly picked this because it had the most thorough reviews. It has lots more exam review sections and questions than any other Java certification book. It is also the most complete in content. I HIGHLY RECOMMEND to anyone that is working with Java and/or studying with certification.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.