File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt About 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 "Doubt About Mock Exam Question?" Watch "Doubt About Mock Exam Question?" New topic

Doubt About Mock Exam Question?

Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
i found this question in Kathy Sierra / Bert Bates monk exam.

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.

Ans given in mock exam is this
A, E, and F are correct uses of generics with (bounded) wildcards.

But when i compile all options independently there is no compile time error for all options.There are compile warnings only for some options.

Please help.
Murali Mohan
Ranch Hand

Joined: Jan 09, 2006
Posts: 66
Yes Gowher!
You are right!
I made a similar mistake in the exam.

Every answer is compiling fine but some are giving warnings.

Thanks,<br />Murali...

Joined: Jul 21, 2006
Posts: 15
is it scjp1.4 or 1.5?
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
I agree. Here's the link:
subject: Doubt About Mock Exam Question?
It's not a secret anymore!