It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes SCJP Mock Exam Question 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 "SCJP Mock Exam Question" Watch "SCJP Mock Exam Question" New topic

SCJP Mock Exam Question

Ashish Laddha

Joined: Apr 12, 2005
Posts: 21
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.

Since, c1 and c2 are non-genric, passing it to generics will compile, albeit with unchecked warnings.

The answer given are A, E, F.
But, B, C, D also get compiled (again, with unchecked warnings)??

So, I think the answer is answer A, B, C, D, E, F
Ashish Laddha

Joined: Apr 12, 2005
Posts: 21
I mean, "since c1 and o1 are ..."
I agree. Here's the link:
subject: SCJP Mock Exam Question
jQuery in Action, 3rd edition