Chung Huang

Ranch Hand
+ Follow
since Jun 21, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chung Huang

The error was on \u0000 right? I thought that \u0000 is null wasn't it? I mean a char variable declared as class member that was not initialized would get \u0000 assigned. I can't remember but wasn't it means null or space or something that means "nothing" If that is the case then it can't be used as identifier.
This program shows you the thing about GC; GC will re-claim memory, but the exact time or the calculation it goes through to find out the time is platform dependent. In Java, you can't force GC to re-claim a particular object, to re-claim objects at particulary, or both. This means as a programmer you can never predict just when would an object that is eligible for garbage collection would be garbage collected.
This program create objects that were not assign any reference to it, so you know that right after you create them they are eligible to be garbage collected. To show you how it work, the constructor prints out message showing you that the objects arecreated. Then, when GC actually do decide to work, the finalize method is executed to show that the object is re-claimed. And at the end, the program prints out just how many object are still alive (it uses a static int to keep track, notice how it increase in consstructor and decrease in finalize method).
For you first question, GC did not work (for some reason it decide not to do any work that time). That is why you see 5 objects being created and all 5 objects were still alive when the program end. The second time, GC did work after the 3rd object was created. Relating to your second question, this is why bye was printed; bye was printed twice because 2 out of the 5 objects created was garbage collected, so each of the GCed objects' finalize method was executed. Because 2 of the 5 objects were GCed, and so at the end of the 2nd run you see that only 3 blobs are alive.
Does this help? And please correct me if I am wrong folks.
I'll do that.
I only have one question dealing with Garbage Collection. And no question that require me to type in. I was lucky in that regard.
First off, I purchase the practice exam from Sun for $75.00. I did not finish the whole thing, its 236 questions. I finish 144 of them. From what I can tell, the practice exam is very close to the actual kind of questions and depth. There are mock exams out there that are harder than the actual exam. Of those Dan�s is the one that pops into my mind. If you could work through his mock exam and either get it right or know why you got them wrong, you�ll do fine. RHE�s book is too light. Some aspects were not cover quite deep. On the other hand, Mughal�s book sometimes goes in too deep. I�ll suggest that go over RHE�s book, as it covers major points, then go into Mughal�s book for explanations and more in depth coverage. While in the Mughal�s book, monitor the forum for topic discussion that would help you. After you gone through your study, take the practice exam from Sun. This practice exam would give you a good handle on how you would do in actual exam, as the two are very close. Now, if you want higher grade, go for the mock exams like Dan�s, getting 80% would probably translate into 80% on your actual exam. The exams from RHE�s book is too light. Passing them with 100% would ensure your knowledge to basic stuff. If the actual exam ask tougher questions, you may not be prepared.
For the actual exam, it does not ask question that require you to think creatively on applying the fundamental Java rules. But, plain memorization isn�t enough as you would have to think what the rules you have memorized mean. Another thing, be patient. The time will be enough. I run into a lot of questions on loops, bitwise operations, and binary operations. There are times when I just simply do the bitwise questions in the dumbest way-I do binary translation and then perform the operation. Yet, I was able to finish with 40 minutes to spare, after I review 10 questions. Don�t worry about time, you have plenty.
The exam questions don't ask you to apply the rules too deep. But, be sure you understand the basics and know all the class names RHE mentioned in events. That is tested.
In conclusion, RHE�s mock exam is lighter than actual. The practice exam from Sun is very close to the real thing. Dan�s mock exam is tougher, but passing it would almost ensure you success.
Time to work on my next cert!
18 years ago
I had just got back from the test center.
I pass SCPJ 1.2 with 67%!
Really low score. However, I figure since all my experience with Java is just that one class I had and about a month and half of study, pass on the first try is really cool!
RHE and Mughal's books are great help! And, spending time here reading posts drives some points into my brain.
Thanks every one!
and one more
18 years ago
Thanks. I'll take more mock exams.
On the objectives listed by Sun, is there a lot of emphasis on the java.awt package and java.io package? I know the basics, but there is just a lot of stuff to be memorized to fulfill all the aspect mentioned. I guess I am just trying to figure out if I could pass with only rudimentary knowledge of the java.awt and java.io package.
Thanks for any comment.
It seems to me that I am running into the so call special this a lot lately.
What is the socal special this? I know that using this means the implicit reference to the object that the method is invoked on, generally. So what is the deal with the format of classname.this.something-else?
I have went over the RHE book and took 3 out of the 4 exams that comes with it. I am getting an average of 80%, is that a good indicator for passing? Because Mughal's book seems to cover things a lot deeper than RHE, so this makes me wonder if going over RHE is not enough.
I am going to take the version 1.2 exam on Monday, this uncertainty is stressing me out.
Is that a static block of code? 'Coz if it were, then wouldn't it be a initializer for the class as whole? Then what happen is that as soon as the class is loaded, that block of static codes get to be executed when buffer wasn't even declared yet. So either put the declaration inside of the static block of code (before the statement where you use it), or you could put the statement that uses it inside a method or constructor.
It does, thanks.
Or, a lazy way would be throw the error up the chain.
Wait a second, if C is super type of A and you say A = B where in run time B is actually referring to C, then I should get a runtime error! Because I thought the rule was that a super class can never be casted into a sub class, the compile may let it slip by but during run time the error would show up.
As a matter of fact, I just run a short program where I did child_object = (Child)parent_object; and it compiles fine. When I run it, every thing executes until I get to the line mentioned, I get a ClassCastException. To me this means that no matter what, only a sub class object can be "changed" into a super class object. For implicit conversion, this is checked. For explicit casting, this rule is not strictly enforced until the line is being executed.
Here is the program I run.

[ July 14, 2002: Message edited by: Chung Huang ]
[ July 14, 2002: Message edited by: Chung Huang ]
-3 in 2's complement is
1111 1111 1111 1111 1111 1111 1111 1101
If you get the above binary number and wonder what is it in decimal, assume you know it is in 2's complement. Look at the left most bit, if it is one, then you are looking at a negative number, if its zero, then you are looking at a positive number. Why? Because that is what 2's complement means. In 2's complement, the left most bit serves the double purpose of representing a number and a flag for the sign of the number. This is why the maximum of a int is 2 to the power of 31 minus 1, because the left most bit being one would indicate a negative number. Back to translation. So how do you translate that long binary to -3? The easiest way I know of is this.
1. Count from the right most bit towards left and stop when you get to the first bit that is 1, we'll call this the index bit.
2. Invert all the bits that are left of the index bit.
3. Translate the resulting binary into decimal as usual.

Does this help you on translating a 2's complement negative number into decimal? Don't let hex or oct confuse you, deep down inside the computer, only 1 and 0 exist and so hex and oct don't mean a thing.
I have a file that is long, but it may help you. It take an integer and put that as the power of 2 and shows you what that would be in decimal and in binary. It deals with integer only, and it basically moves the 1 bit up and down and shows you what it will be in terms of decimal. If you want, I'll post the code for you.
[ July 14, 2002: Message edited by: Chung Huang ]
Some where on my hard drive I have a java program that takes a number, show its binary presentation, then do all those bit operators on them, and display the result in both the number it comes out to be and the binary presentation of the number.
What is the point of telling you this? There is a method some where that lets you print out binary presentation(thought it cuts off all the leading zeros). I'll suggest that you write a program that do what I had done. It helps me out a lot, since I get to see what I have to start with and what I end up with.
I'll dig around for that method and let you know what it is...I think its part of the wrapper class for all those number types.
Nope, I lied.
I look it up, in Interger (the wrapper class) there are three methods that takes an int type and return a string representation of that int as binary, hex, or octal.

hope this helps
[ July 14, 2002: Message edited by: Chung Huang ]
I forgot which book I read this from, but it basically said what you guys said; while string pool is not GCed, for the purpose of answering mock exam questions, assume that string pool can be GCed.
If I run across a question on string literal and GC, if "not eligible" is not one of the answer, I'll be sure to write to Sun about it!
Thanks guys! This helps me a lot.