I have been preparing for the OCPJP exam for the past 3 months. I have scheduled my exam (its within one week from now) but I am really worried I have followed SCJP Preparation book by K&B and I believe I understood the basic concepts underlined in the book.
I am taking the simulated exams from ExamLab and the score is really poor I have also followed the OCP Exam Preparation and there as well the score is just the same 50% only
There's a dedicated forum for SCJP preperation/doubts etc. You will get better help there.
Also, it would helpful if you provided further details like in which areas you are scoring low? or what type of problems?
It is very important to understand exact type of problem in SCJP/OCP. e.g. a code snippet with couple of synchronized blocks might fail due to absence of a semicolon etc.
All the best.
Agree. I shall move this discussion thither.
Anayonkar Shivalkar wrote: . . . There's a dedicated forum for SCJP preperation/doubts etc. You will get better help there. . . .
Especially on the formatting and exceptions, I get confused when its time to decide between compile time error or run time exception
But thankyou all, I will refer to the appropriate forum
I don’t understand what you said about exceptions and compile-time errors.
I get confused as to when would this be reported. I had a tough time understanding the ClassCastException thrown at runtime and inconvertible types compile time error.
Kaur Manpreet wrote:I had a tough time understanding the ClassCastException thrown at runtime and inconvertible types compile time error.
Well, it is not much difficult to identify if you understand inheritance hierarchy.
Inconvertible compile time error occurs when compiler knows for sure that type of the references are not convertible at all. ClassCastException occurs when casting of references is possible, but at runtime, actual objects are not convertible.
This happens because, at line 7, compiler knows that d is a reference of type Dog, and there's no way that it can refer to a Cat object, so, at compile time itself, there is an inconvertible type error.
But at line 9, animal is a reference of type Animal, and there is a chance that it can refer to either Animal, Cat or Dog object. So, compiler doesn't complain about this casting. But at runtime, animal is actually referring to a Cat object, which cannot be converted to Dog object(or, to be specific, a reference of type Dog cannot refer to Cat object), and hence, there is a ClassCastException.
I hope this helps.