Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generics Question:

 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I prefer to choose a,c,d.

What do you "Java community people" say about my chosen options?

Source: Voodoo exam simulator!


Regards,
cmbhatt
[ April 21, 2007: Message edited by: Chandra Bhatt ]
 
Arad Chear
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ummmmmmmm i'will back
[ April 21, 2007: Message edited by: Eisa Ayed ]
 
Arad Chear
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i find only two statement true !




classA {}
class B extends A {}
class C extends A {}
class D extends B {}
class E extends B{}

Which three statements are true?
a. The type List<A> is assignable to List.// yes

b. The type List<B> is assignable to List<A>. // must be same type

c. The type List<Object> is assignable to List<?>.// No
//List<Object> mean this list can hold only List<Object> not List<A> or List<B> or list of any thing List<?>

d. The type List<D> is assignable to List<? extends B>. // No
//List<D> cannot hold List<E>

e. The type List<? extends A> is assignable to List<A>.// yes
//List<? extends A> any List hold Objects from subclass of A can hold to List<A> which is superclass for them

f. The type List<Object> is assignable to any List reference. // No
// its like c
g. The type List<? extends B> is assignable to List<? extends A>.// No
// List<? extends B> cann't hold List<C>


 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eisa,

You took options E,D,G wrongly.
Here I did some effort





Correct me!



Thanks,
cmbhatt
 
Louis Moloney
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i believe the correct answer is : a,c,d,g

f List<Object> is assignable to many refs but not all eg List<? extends B>

 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Moloney,


i believe the correct answer is : a,c,d,g


And you have strong believe! a,c,d,g are correct answers. (I say too)

But the source of question says only c,d,g are correct.


Regards,
cmbhatt
 
Louis Moloney
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
excellent, looks like we must watch out occasional wrong answers on exam simulators.

I think generics are a very trciky topic, they diffiately confuse me sometimes !
[ April 22, 2007: Message edited by: Louis Moloney ]
 
Arad Chear
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually i misunderstand the meaning of the sentence

maybe because i didn't speak very well in English Language ! ,

i thought it , like this :



Thanks Chandra
[ April 22, 2007: Message edited by: Eisa Ayed ]
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very good Eisa,


I think you have got the soul of the generics, and specially
this kind of questions.

We should read the questions very carefully. Sometimes we know
the concept but due to the reason, we overlook the things, we go
wrong. It may happen with anybody.



Thanks Eisa for getting me close to the answer.




Thanks and Regards,
cmbhatt
 
Alam Ameghino
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Firt, sorry for me bad english, it is so bad.
For me it is wrong too.
Besides if the asigment are to rigth -> left, or left -> rigth, never there are 3 answer correct.



For me the question is wrong, in relation of the amount of answer correct.

I hope that someone can undertant me bad english! ;-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic