my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Q on Generic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Q on Generic" Watch "Q on Generic" New topic
Author

Q on Generic

Deepti Bhatia
Greenhorn

Joined: Oct 19, 2006
Posts: 25
Hi,

Below is a question from javabeat.

41)which are all valid method(s) inserted independently will allow program to
compile

a public Object get() { ... }
b public Long get() { ... }
c public void set(Object arg) { ... }
d public void set(Long arg) { ... }
e public Number get() { ... }

Ans - b,d,e

why not a,c ?
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
because object is superclass of number and all other are subclasses of number. and type E is set to number.


SCJP 1.6 96%
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Q on Generic