Wu Wen

Greenhorn
+ Follow
since Oct 14, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
3
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 Wu Wen

Anyone can explain me this patter?

".*[A-Za-z]+\\s?[12][0-9]{8}.*|^([12][0-9]{8}).*"

Thanks a lot

anoop ashtekar wrote:
Hello Friend,

Congrats about passing scjp 6 . kindly brief me up the topics on which you majorly
had questions in the exam

Once again congrats And all the best for your further endeavours!!

Thanks
Anup



Thank you.
As I remember, there are a lot of questions on OO, override, overload. Some questions are tricky, but you will be used to it if you do enough mock test.
Two assertion questions, one garbage collection, three or four thread questions. a few I/O question, one Regex question.
I got one IO and one Regex question wrong, which are very basic, I wouldn't miss it if I write a few more samples.

I had 50 minutes left when I completed my exam, then I reviewed all marked questions, I found the real exam are easier than the mock test. I was using enthuware as my main mock test, the questions and the format are similar to the real exam. There are a lot of free mock test available on internet as well.

I will suggest give enough time to do mock test before the exam, the text book is good, but not enough for the exam. I took 6 sets mock test and used one week to review everything before I finally took the exam. I failed in my first Mock test, but passed the rest.

Hope it gives you some idea.



I passed the exam today at 86%, the exam is easier than the mock test(Enthuware) I took, but it really covers all the objectives.
I made several mistakes on some very basic concepts like assertion, File, Regex. I should have reviewed more.
My weakest part is thread, so last one month I spent a lot of time on this forum reading old posts, it helped a lot.

Thanks for providing this nice place for us.

Sebanti Sanyal wrote:Inside method go(),two objects are created. f3 refers tothe object originally referred by f2. That particular object has a member variable f,which again refers to the object initially referenced by f1. Therefore, none of the two are eligible for GC at line 18. If we also had f3=null;, the two objects would still had referenced each other but none of them could be accessed externally and hence eligible for GC.
In main(),one object is created on which go() was invoked.That object was created on the go,and there is no reference associated with it.Hence, it is definitely eligible for GC at line 8.The two objects created inside go() were accessible only with a local variable f3,which does not live anymore after go() returns. These two can also be garbage collected at line 8.



Thank your for the explanation it is very clear.

If I remove base=null, what will be the result? I'm a little confused because base is static. Thanks

Larsen Raja wrote:Missed the SOP in getH functions.

1. In any statement if there is an internal call to a method that method gets executed frist.
For example: If theres a call to a method A() in main(), A() needs to be completed first before main() reaches termination.
Likely, A(B()); In this case, B() needs to be executed first before A() returns.



Thank you, now I get it

Henry Wong wrote:
Please QuoteYourSources



The question comes from OCP Java SE 6 Programmer Practice Exams Page 181


Which are true? (Choose all that apply.)
A. At line 8, one object is eligible for garbage collection.
B. At line 8, two objects are eligible for garbage collection.
C. At line 8, three objects are eligible for garbage collection.
D. At line 18, 0 objects are eligible for garbage collection.
E. At line 18, two objects are eligible for garbage collection.
F. At line 18, three objects are eligible for garbage collection.

The right answers are C, D. Anyone can explain me the steps in detail? Thanks a lot

Ankit Gareta wrote:Here in SOP it called the override method... so the answer should be something like that....


Beta 44
4 44
Beta 44
44 44

as Laren said... the variabels will be used based on the reference type. so in first SOP the b.h = 4 ...



This is the right answer, I understood the polymorphism part, but I don't know why Beta 44 is printed before 4. Please advice, thank you


I was expecting 4 is printed first, but how come Beta 44 is printed first?
I think my question is more about System.out.print().


Why it prints out index = 2 instead of throwing an exception at //1 ?
t1.join() means current thread will join after t1 completes, and current thread is the main thread, no the other thread Checkout2.

Congratulations!

I have a question about the exam, the practice given in K&B book doesn't tell you how many options are correct in each question.
But in the mock tests I found on line normally tell you how many options you should choose. How does it looks in real exam?

Thanks
7 years ago
Congratulations!
I also have a question, the practice given in K&B book doesn't tell you how many options are correct in each question.
But in mock tests I found on line normally tell you how many options you should choose. How it looks like in real exam?

Thanks
7 years ago

Tina Smith wrote:You should synchronize on the class in your run() method, not in main where the threads are being constructed.

Because threadcounter is static and shared by all instances of TestClass (and exists even without an instance of TestClass), you can't lock on an individual instance of TestClass. So what you need is to be able to lock all objects out from accessing threadcounter while you are using it. You could always declare a static Object in TestClass and then lock on that object to lock the primitive, but Java provides a more elegant, built-in way of doing this: TestClass.class. There is only one ".class" for all instances of TestClass, so locking the "class" field will lock anything shared.

I probably should remember whether locking the class locks the instance methods/fields as well...I seem to think it doesn't but again I could be wrong.

Synchronized will lock on whatever you give it, if you try to lock on any instance of TestClass you won't have much luck; because threadcounter is static your lock object MUST also be static. You're also in the same boat if you provide getters and setters; they have to return a primitive which you cannot lock.



Thanks for your reply, I'm not sure I understood. If locking the "class" field will lock anything shared, why the final value of threadcounter just before the program terminates may be less than 10?