New SCJP mock exam
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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 ]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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

-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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?

-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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 ]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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:
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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 ]
<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
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
unless i'm doing something wrong..-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Actually it is method doSomething() I'm talking about. Sorry about that... I've fixed it.
[ February 20, 2002: Message edited by: Valentin Crettaz ]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
Director of Engineering, Twin Health, Mountain View, CA, USA
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I've fixed it...
Tosin,
yeah you should keep it for the last week...
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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...
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
everything you pointed out was right... I've fixed them... Thanks a lot

-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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 ]
Rob
SCJP 1.4
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Obviously I'm not a linguist
Thank god, Java is much more interesting than linguistics... 
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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 ]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
SCJP 1.4
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.
Rob
SCJP 1.4
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Wow - I wonder if the people at Sun are this nitpicky about every question?
Corey
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Rob
SCJP 1.4
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Good question - definitely a mind bender.
Corey
[ February 21, 2002: Message edited by: Corey McGlone ]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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

-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
We create an array of 4 Object...
Hmmm...looks like just 3 objects, to me.
Corey
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Keep it up.!
Sonir
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
[ February 24, 2002: Message edited by: Valentin Crettaz ]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
| Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |







