• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Generics Question

 
Ranch Hand
Posts: 72
Eclipse IDE Firefox Browser Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given a method declared as:

public static <E extends Number> List<? super E> process(List<E> nums)

A programmer wants to use this method like this:

// INSERT DECLARATIONS HERE

output = process(input);


Which pairs of declarations could be placed at // INSERT DECLARATIONS HERE to allow the code to compile? (Choose all that apply.)

a)ArrayList<Integer> input = null;
ArrayList<Integer> output = null;

b)ArrayList<Integer> input = null;
List<Integer> output = null;

c)ArrayList<Integer> input = null;
List<Number> output = null;

d)List<Number> input = null;
ArrayList<Integer> output = null;

e)List<Number> input = null;
List<Number> output = null;

f)List<Integer> input = null;
List<Integer> output = null;

g)None of the above.


this is a question from KS&BB, chapter 7 self test q#16.The answer given is B,E and F...which i think i understand, however i cannot see why C is also not right??please help..thank you!
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Janardan,

Check this thread out: https://coderanch.com/t/268612/java-programmer-SCJP/certification/SCJP-Chapter

Looks like you have an outdated copy of the book...
 
Janardan Kelkar
Ranch Hand
Posts: 72
Eclipse IDE Firefox Browser Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ohh...thank you very much....my wrong i guess..
have my exam tomorrow
 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All the best!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic