wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes New SCJP mock exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "New SCJP mock exam" Watch "New SCJP mock exam" New topic
Author

New SCJP mock exam

Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
I've gathered some frequently asked questions lately and created a new mock exam in order to bring some fresh problems to the question pool.
Basically, there are no easy questions at all. Only hard to real brainer ones, much like in Bill Brogden's hardest questions mock.
So be advised and don't take it too soon during your study or your confidence might be hurt a little
Every question has a brief comment, as well as links to the relevant parts of the JLS and the API, so that you know where to search for further information.
Let's get to work : Valentin's mock exam
Any comments, corrections, improvements and additions are more than welcomed (You'll get the credit, don't worry ). Feel free to let me know.
[ February 20, 2002: Message edited by: Valentin Crettaz ]

SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Erik Dark
Ranch Hand

Joined: Jan 28, 2002
Posts: 107
Took a first short peek at it and it looks great! Going to save it for the last week...
Also read "You said "Certification"?"...quite interesting, I agree on a lot of points you make (though not all!).
Thanks (in advance) for all the effort and time you spent on people trying to learn something!
Erik Dark
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Thank you Erik
A free application will be available soon, I just need to stack up a bunch of questions first.
Concerning the article, I don't expect everybody to agree with my opinions, of course. I wouldn't write if I had no opinions :roll: ...
Anyway, thank you very much for your feedback and good luck
chafule razgul
Ranch Hand

Joined: Feb 09, 2002
Posts: 63
Can i draw your attention to question 15?...
I'm trying the code, and don't seem to be coming up with two options resembling those available as answers..
It seems curious to me that even when i commented out say
char c = '\u000z'
i'd still be getting errors until i escape the offending \.. why does the compiler not ignore the commented, abeit illegal character definition?
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Because the compiler doesn't like \u000a even within a comment.. you have to delete it completely in order for the code to compile.
For instance, a comment like
// some comment \u000a some comment
is parsed as
// some comment
some comment
[ February 20, 2002: Message edited by: Valentin Crettaz ]
Rajinder Yadav
Ranch Hand

Joined: Jan 18, 2002
Posts: 178
Valentin, question 7 seems to be missing the line numbers? About the following question,
The cast on line 4 is mandatory.
There is no cast op at line four??? The literal line four is:
interface E{}
can you please fix this!
[ February 20, 2002: Message edited by: Rajinder Yadav ]

<a href="http://www.rajindery.com" target="_blank" rel="nofollow">Rajinder Yadav</a><p>Each problem that I solved became a rule which served afterwards to solve other problems. --Rene Descartes
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Thank you Rajinder, I've fixed it.
Don't hesitate to let me know if you find more of them...
If you don't want to reload it, here is the correct code:
Rajinder Yadav
Ranch Hand

Joined: Jan 18, 2002
Posts: 178
Val it's me again
Q8 doesn't seem to be finished?
Question 8. How many objects are eligible for garbage collection when method
Which of the 2 method are you talking about? does what, ends?
[ February 20, 2002: Message edited by: Rajinder Yadav ]
chafule razgul
Ranch Hand

Joined: Feb 09, 2002
Posts: 63
Question 17, similar situation with question 15.. result of compiling and running code is not in the choices available.. unless i'm doing something wrong..
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
You are right.
Actually it is method doSomething() I'm talking about. Sorry about that... I've fixed it.
[ February 20, 2002: Message edited by: Valentin Crettaz ]
chafule razgul
Ranch Hand

Joined: Feb 09, 2002
Posts: 63
Actually i'm wrong, please disregard issues pertaining to 15&17
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

Valentin,
You have done wonderful job for the ranhers! Really appreciate your step....its look & feel is same to javaranch ... ...
Hope you continue serving here....


Ashik Uzzaman
Senior Member of Technical Staff, Salesforce.com, San Francisco, CA, USA.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Nice exam, Val. I passed - not by much, mind you, but I passed. Think I'm ready to take the exam?
One little nitpick. I noticed, on question 44, you state, "Select two correct statements..." However, there is only one correct answer and you have radio buttons rather than checkboxes to reflect that. It looks like a simply typo in the question title.
Thanks again, Val,
Corey


SCJP Tipline, etc.
Tosin Adedoyin
Ranch Hand

Joined: Nov 09, 2001
Posts: 43
Thanks Valentin ,
for the mock exams it looks like the real deal if not tougher i felt i did not know anything
i need to hit the books more. i will save if for the last week too
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Thank you Corey,
I've fixed it...
Tosin,
yeah you should keep it for the last week...
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
That's a really good test Valentin. And very very hard!
Useful tip: don't try taking this test at 1am when you're falling asleep!!
Here's a few "bugs" in your test that I noticed:
Q25: asks "Question 25. What is the output of the following code when compiled and run?"
However, it doesn't say how many correct answers there are. (According to the results, there are 2 correct answers)
Q36: One of the correct answers is E:
E. The array creation expression on line 1 is legal even if the given size is 0.
However, in the sample code, the line marked "line 1" has no array creation expression on it. The line with the array creation expression isn't actually labeled at all.

Q39 :Answer E states:"An IllegalAccessError is thrown at runtime because i is not accessible on line 1."
But there is no line one labled in the souce code.
There are also a couple of answers I disagree with, but I will test them out fully before I challenge them

But anyway, this was a really good test. Thanks for your efforts!!
Valentin ==


Rob
SCJP 1.4
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Here are a couple more typos:
Question 6 Comments

First, b=!b is evaluated...

It is really b!=b, not b=!b.

Question 11 Comments

We then store the reference to buf (which references the same obejct as buf1 into a local StringBuffer called b. From now on, every changes made to b are only affected b and not buf1 anymore.

WHAT!?!? Obviously, you've got this backwards. b and buf1 must still reference the same StringBuffer object or the call to b.delete(...) would not have the effect that it has on buf1.

Corey
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Thank a lot Rob,
Q25: asks "Question 25. What is the output of the following code when compiled and run?"
Actually I saw that just 2 minutes before you pointed it out and I fixed it in the meantime...

Q36: One of the correct answers is E:
E. The array creation expression on line 1 is legal even if the given size is 0.

You are right... Silly cut and paste
Q39 :Answer E states:"An IllegalAccessError is thrown at runtime because i is not accessible on line 1." But there is no line one labled in the souce code.
Actually there is but I know I've just fixed it like an hour ago...
There are also a couple of answers I disagree with, but I will test them out fully before I challenge them
Just tell me if you think something is weird... Thanks a lot...
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Thank you Corey,
everything you pointed out was right... I've fixed them... Thanks a lot
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
Question 8: I think your answer is incorrect. The stated answer is 3, but based on the wording of the question, it should be 4.
How many objects are eligible for garbage collection when method doSomething() returns? Select one correct answer.

When the method doSomething() returns, control resumes at the line just after the statement
new Question08().doSomething();
At this point, the Question08 object is also eligible for gc. So the answer to the question should be 4, not three. If you want to limit the scope of the question to the actual doSomething() method, I would suggest you change the wording of the question to read "How many objects are eligible for garbage collection just before method doSomething() returns?".
This is why Sun hires linguists to exam the test language in detail to clear up these little details.
[ February 21, 2002: Message edited by: Rob Ross ]
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Thank you Rob, I'll change that right now...
Obviously I'm not a linguist Thank god, Java is much more interesting than linguistics...
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Rob Ross:
"How many objects are eligible for garbage collection just before method doSomething() returns?".

But I think this changes the meaning of the question. The real trick here is that you have to realize that the array itself is an object and therefore is eligible for garbage collection. If you say, "How many are eligible just before the method returns?", that implies that we are still in the method and, therefore, the array (and it's elements) are still in scope, making the correct answer 0.
Personally, I liked the wording the way it was, but maybe you could just assign the new Question08 object to a reference in main. Something like this:

In my opinion, however, I think it's fine.
Corey
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Okay, I've done something else.
Just added
Question08 q28 = new Question08();
q28.doSomething();
Thread.sleep(20000);
and rewrote the question as it was before...
That oughta do it...
What do you guys think ?
[ February 21, 2002: Message edited by: Valentin Crettaz ]
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
I don't agree with the answer to number 16. There are actually 3 correct answers, rather than 2. I think that B, C, and E are all correct.
The code is as follows:

As ArithmeticException extends RuntimeException, you do not need the try/catch block in order to compile this code. If you don't catch it, an exception will be thrown at runtime, but the question is somewhat ambiguous as to what the try/catch is required for. I took it to mean: "The try/catch block is not necessary to compile the code successfully."
Corey
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
One thing I've seen on mock exams that helps to make it crystal clear is using line numbers, and asking "how many objects are eligible for gc at this line number?"
Question08 q28 = new Question08();
q28.doSomething(); //line 1
Thread.sleep(20000);
Now if you ask "how many objects are available for gc immediatly after line 1", I think it's very clear what the question is asking and what the exact answer should be.
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
Originally posted by Corey McGlone:
I don't agree with the answer to number 16. There are actually 3 correct answers, rather than 2. I think that B, C, and E are all correct.

Hey no fair, I was just about to write the same thing!@! :roll:
But I completely agree. ArithmeticException is a runtime exception, and does not need to be caught, because it's unchecked.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
I don't think you need the call to sleep(). Since you've assigned a reference to the object to the variable q28 and q28 hasn't gone away, after returning from the method, there is no reason the Question08 object should be garbage collected. The variable q28, which is still in the active part of the program (remember, the method doSomething just returned, main hasn't), still references the Question08 object, therefore, it is not eligible for garbage collection, regardless of the sleep() statement.
Wow - I wonder if the people at Sun are this nitpicky about every question?
Corey
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
They better be!!! I want to know exactly what the problem is I am solving for each test question, and not have to guess what they meant.
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
You are right guys, I've fixed, question 8 and modified option E of 16...
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Okay - I admit it - I was entirely baffled by the answer to 24. I would never have guessed that you can really call a static method on a null reference. Of all the inane things to do in your code...
Good question - definitely a mind bender.
Corey
[ February 21, 2002: Message edited by: Corey McGlone ]
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Gotcha
Actually if you come to think of it it's more than logical since static methods don't need any target reference but I admit that one is kind of tricky
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
I think I found another typo:
Question 28 Comments:


...at the first iteration k=0 and j=2...

At the first iteration of the inner loop, won't j = 3? It should have been incremented by the postincrement operator in the condition of the outer loop, right?
Corey
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
nope it gets decremented to 2 just after the test...
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Valentin Crettaz:
nope it gets decremented to 2 just after the test...

You're right - I was thinking about what j was when the test of the inner loop is performed. When the inner loop begins (just after the test is performed), j is decremented back to 2. Sorry for the misunderstanding.
Corey
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Comment for Question 41

We create an array of 4 Object...


Hmmm...looks like just 3 objects, to me.
Corey
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Yup right... sorry about that...
sonir shah
Ranch Hand

Joined: Nov 01, 2001
Posts: 435
Excellent work Val..
Keep it up.!
Sonir
Erik Dark
Ranch Hand

Joined: Jan 28, 2002
Posts: 107
Going to save it for the last week...

As I quoted myself I was wondering where to place this mock compared to the real thing. Suppose Rob, Corey and Val himself could give an indication?
Erik Dark
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
This exam is much more difficult than the real thing and its purpose is to test you on difficult topics by means of hard questions. There are deliberately no easy questions at all.
[ February 24, 2002: Message edited by: Valentin Crettaz ]
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Erik Dark:
Suppose Rob, Corey and Val himself could give an indication?

Well, I scored about a 70% on it and I'm planning on taking the real exam tomorrow. I'll let you know how I think the two compare after the exam.
Corey
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: New SCJP mock exam