File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Generics ques...pl help explain Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Generics ques...pl help explain" Watch "Generics ques...pl help explain" New topic
Author

Generics ques...pl help explain

Pav Arora
Greenhorn

Joined: Dec 17, 2007
Posts: 28
When I went thru KB, I thought I have understood Generics. I am not getting the following question -



Which inserted at // will compile

a) class Pie<T extends Food> {
b) class Pie<T extends Fruit> {
c) class Pie<T extends Apple> {
d) class Pie<T extends Pie> {
e) class Pie<T super Apple> {
f) class Pie<T>{
sree visu
Ranch Hand

Joined: Jul 05, 2007
Posts: 133
i am not sure about the answer but i hope "B" is the correct answer .this is because Pie<Fruit> p=new pie<fruit>(); ..so here anything that the class can take must be that extends fruit.


Regards<br />Sree Visu<br />SCJP 5.0, SCWCD 5.0, SCJD(Preparing B&S 2.2.2)
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
a, b, and f should work

Apple is a subclass of Fruit so c won't work.

Pie has no relation to Fruit so d won't work.

super isn't used in a generic class definition so e won't work.
Pav Arora
Greenhorn

Joined: Dec 17, 2007
Posts: 28
Thanks guys.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generics ques...pl help explain
 
Similar Threads
Use of generic term super in class declaration
Generic question
Generic question from Master Exam
generics super keyword
Generics <?>