aspose 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply 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: 2341
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Generics ques...pl help explain
 
Similar Threads
Generic question from Master Exam
Generics <?>
Generic question
Use of generic term super in class declaration
generics super keyword