Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes A mock sampler from K & B - Java 5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "A mock sampler from K & B - Java 5" Watch "A mock sampler from K & B - Java 5" New topic

A mock sampler from K & B - Java 5

Bert Bates

Joined: Oct 14, 2002
Posts: 8898
Hi Guys!

Here you go... a huge batch (well ok, there are 11) of mock questions from the upcoming K & B Tiger cert. book. We tried to slant this batch towards the new features in the exam. If we're able to get another batch out in a week or two we will, but no promises. Honestly we're pretty focused on getting the book done

As always, feedback is appreciated (they say, shaking in their boots).

Bert & Kathy

Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Marcus Green
arch rival

Joined: Sep 14, 1999
Posts: 2813
I note that the questions tend to have more answer options, i.e. 6 options. A to F, Is that fairly typical of the new exam?

SCWCD: Online Course, 50,000+ words and 200+ questions
Bert Bates

Joined: Oct 14, 2002
Posts: 8898
Hey Marcus,

I'd say they tend to have more options, plus there are a LOT more drag and drop style, which is another way of having more options. So in this sampler we had 9% drag and drop, it's probably more like 20% on the real exam. Finally, I'd say that in general, the code samples are a lot longer than they used to be, so lots more clicking the exhibit button. (For those of you who hate the exhibit button, I must confess that I hate it too! I didn't write a single question that needed the exhibit button... on the other hand a wrote a few pretty ugly pieces of code to jam it all into 12 or 14 lines )
Karthik Hariharan
Ranch Hand

Joined: Aug 14, 2005
Posts: 31
Tough questions! Might have done better if I knew how many choices are needed for a correct answer on each question. Still its good practice.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

I think the great thing is that they are really really tough. because if the mocks are tougher than the real exam, which is tough to do, then you can hope for better success on the real exam.

Marcus - Yes the real questions have more options and much more code.

Unlike Bert, I like pissing people off so a lot of the questions that I wrote use Exhibits.

[ August 30, 2005: Message edited by: Mark Spritzler ]

Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Akshay Kiran
Ranch Hand

Joined: Aug 18, 2005
Posts: 220
Hi Bert,

I think I spotted an error in the mock sampler.
Question 11.
11. Given:

1. import java.util.*;
2. public class Fruits {
3. public static void main(String [] args) {
4. Set c1 = new TreeSet();
5. Set o1 = new TreeSet();
6. bite(c1);
7. bite(o1);
8. }
9. // insert code here
10. }
11. class Citrus { }
12. class Orange extends Citrus { }

Which, inserted independently at line 9, will compile? (Choose all that apply.)

A). public static void bite(Set<?> s) { }
B). public static void bite(Set<Object> s) { }
C). public static void bite(Set<Citrus> s) { }
D). public static void bite(Set<? super Citrus> s) { }
E). public static void bite(Set<? super Orange> s) { }
F). public static void bite(Set<? extends Citrus> s) { }
G). Because of other errors in the code, none of these will compile.

11. A, E, and F are correct uses of generics with (bounded) wildcards. (objective 6.4)

Intuitively, one might be led to believe that your answer is correct, however, all the options A through F will COMPILE and all except A will generate a warning, simply because what has been passed is a java.util.Set and what is expected is java.util.Set<some type or type range>
A doesn't generate a warning because java.util.Set passes correctly for java.util.Set<?> (a "no type" will pass for "some type")

I have a feeling that you intended Citrus to extend Fruits, which is absent, and therefore your theory of correct generic bounded typing fails. Another thing you might have missed is Set<Fruits> c1... and Set<Fruits> o1...
In which case, both the modifications made, your answer A and E will fit correctly. However, I do not know how you would purport to include E which requires a Set<? extends Citrus> will not include a Set<Fruits> etc.

A confession:
I'm ratiocinating simply because this is the only topic I seemed to have covered of the SCJP answerable in your sampler, (also the only question which I was sure of getting right ) hehe I hope I'm not wrong about what 've written here.

"It's not enough that we do our best; sometimes we have to do<br />what's required."<br /> <br />-- Sir Winston Churchill
Bert Bates

Joined: Oct 14, 2002
Posts: 8898
Akshay -

Arg! You're right - what you actually spotted was a glitch in getting HTML to play nice with our generics code!!! Luckily, the book won't be in HTML!

So, try substituing these two lines of code for the ones you see in question 11...

Set<Citrus> c1 = new TreeSet<Citrus>();
Set<Orange> o1 = new TreeSet<Orange>();

Sorry everyone, we're fixing the page right now!

Akshay - Thanks for the great catch!

- Bert
Kathy Sierra
Cowgirl and Author

Joined: Oct 10, 2002
Posts: 1589
Howdy all,
Akshay -- thanks for catching that. I'm a bad, bad HTML programmer and didn't even notice that I lost some angle brackets there...

Anyway, I fixed it, so the question 11 code should be correct now.

Thanks and have fun in your studies everyone. As much fun as WE had making the SCJP exam hard, I mean, *better*,

Akshay Kiran
Ranch Hand

Joined: Aug 18, 2005
Posts: 220
Whoa, the next time I find something wrong, I'll try to tone it down as much as possible, your humility makes me ill at ease. I should probably have more faith in the experienced crew
I agree. Here's the link:
subject: A mock sampler from K & B - Java 5
It's not a secret anymore!