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 Q on Generic 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 "Q on Generic" Watch "Q on Generic" New topic

Q on Generic

Deepti Bhatia

Joined: Oct 19, 2006
Posts: 25

Below is a question from javabeat.

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

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:
subject: Q on Generic
It's not a secret anymore!