Asad Zubair

Ranch Hand
+ Follow
since May 08, 2011
Asad likes ...
Eclipse IDE Firefox Browser Java
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Asad Zubair

I am not sure if I can explain it better than the KB book here but I'll try.
Your pattern in simple english is "give me anything that is zero or more characters followed by xx". If you look at your source, without consuming it, you have the following matches.

The greedy quantifier, being greedy in nature, wants to consume as much as it can so it returns the largest match (yyxxxyxx).
The reluctant quantifier is the opposite and wants to consume as less as it can before moving on (yyxx). After moving on, the reluctant quantifier sees another match (xyxx) and returns that as well.
That is incorrect. It is 61%. I know because I just gave it last week.
Another "loose" reason of putting it is the whole concept behind interfaces and abstract classes. An interface is thought of as equipping a class with an ability whereas an abstract class is thought of as associating a class to a particular type.

For example, going back to textbooks, A Ferrari is a type of car with a special ability to doSportyThings. The Car can be an abstract class and the doSportyThings() method can be coded inside an interface called Sportable. This way, the Sportable capabilities can be provided to other Car models on a case by case basis, rather than making Sportable an abstract class which would then make every type of car a sports car.
In my opinion the difficulty level really depends on your preparation and practice.
The people on this forums who got their percentage in the 90s will probably tell you that it was not that bad. I personally found it a bit more challenging than expected but then, maybe I did not prepare enough. Once thing I can say for sure that it is definitely easier than ExamLab. So if you can do well on that, then you should be in good shape.
12 years ago
Yes there were questions about wait(), notify() and notifyAll() in the exam.
12 years ago
Yes it is 2.5h with a pass of 61%
There were no serialization questions, which was a bummer for me as I always scored well on this topic in the mock questions. There were quite a few thread questions though.
12 years ago
There were no drag and drop or fill in the blank questions. Only multiple choice. Nothing that caused the answer to wipe out on review.
I can confirm what Aashu mentioned about Pearson. They just give you your total percentage at the end and then list the objectives which you got wrong. I dont have any experience with Prometric so I cannot speak to that.
I did feel that 150 minutes was a bit too short for me. I was only able to review like 4 questions before my time was up. The extra 30 minutes that Prometric offered would have been a huge bonus for me.
I liked the "Strikeout" feature, where you could strike-out the options that you know for sure are not correct. It got me to focus on the options that could be correct.
12 years ago
80%. I know it not as high as some of the other folks here, But will full time work, kids and just 3 months preparation, I will take it. I can still call myself an OCPJP now
Thank you javaranch !
12 years ago
As I start to play with the code a bit more, it makes more sense now. The execution happens differently for comparison operators vs assignment operators (due to the over-writing concept). I previously thought it was the same. Anyways, nice little exam gotcha that I should be prepared for now. Thanks for the comments !

Thanks Matthew,
It still does not make total sense to me why the post increment gets overwritten rather than being evaluated after line 2 completes. However, looks it is a JLS rule and I just need to burn it in for the exam.

This is something you get better at with practice. There are lots of little compiler rules that you start to get familiar with as you go through the questions in the KB book and the mock exams found here. There are some situations (like using a variable that is out of scope) that you think it would make sense for the compiler to complain while reading through the code. Then there are other situations where you just have to memorize compiler/runtime rules (like calling wait() in a non-synchronized context will compile but throw a runtime exception) to determine what the error is. I have mostly seen compile warnings in questions involving generics (emphasis on the word mostly).

In short, it does take time, effort and patience (to not throw your PC out of the window) before you start to think like a Java compiler
Guys, I believe you have missed the point in my question. Why does my code print 15 and not 16 ? Should the post increment not kick in after line 2 is finished but before line 3 is executed ?

Ryan, your re-written code is printing 16, not 15. Even though I thought it would execute the same way as my code (which prints 15)

The following code snippet prints 15. I was expecting it to print 16.

It seems like it is not using the post increment (s++) to increment s by 1 after evaluating s as (s=5+5+5 = 15). This is surprising to me as s is being printed in the next line and I thought that would be enough for the post increment to kick in before the printing occurred. Could someone please clarify my doubts here ?
Hi folks,

There is list of exceptions in the KB book that classifes them as thrown by JVM or programmer. However, I could not find a proper list in the book or the forums that classifies them by checked vs unchecked. So I have a compiled a list here of the ones I have encountered in the book and mock exams for you guys to use as a resource. (Enjoy).
If there is any that you have encountered, feel free to add to this list but please limit your responses to your findings in mock exams/KB book only.


Option E is not correct because although there will be 2 errors thrown, it is highly likely (although not guaranteed) that more output will be produced. This is because there is a new thread being started (t3 and t4) just before the error is thrown so they will continue to run and print separately regardless of the errors being thrown by t1 and t2.