Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 222191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:06:15+00:00 2026-05-11T19:06:15+00:00

The question below is from Java SCJP5 book by Kathy Sierra and Bert Bates.

  • 0

The question below is from Java SCJP5 book by Kathy Sierra and Bert Bates.
Given a method declared as:

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

A programmer wants to use the method like this:

// INSERT DECLARATIONS HERE
output = process(input);

Which pair 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.

Correct Answers given are: B, E, F and the explanation in the book states:
“The return type is definitely declared as List, NOT ArrayList so A,D are wrong. ……”

This is what I don’t get…why it is that the return type MUST be List only and not ArrayList?? Just like the argument can be ArrayList then why cant return type also be arrayList?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:06:15+00:00Added an answer on May 11, 2026 at 7:06 pm

    This is actually not specific to generics, but deals with types.

    Easy way to think of it is, an ArrayList is a List, but an List is not necessarily an ArrayList.

    ArrayList implements the List interface, so it can be treated as a List. However, just because something implements List, it is not an ArrayList. For example, LinkedList implements List, but is not an ArrayList.

    For example the following are allowed:

    List arrayList = new ArrayList();
    List linkedList = new LinkedList();
    

    This is because both ArrayList and LinkedList both implement the List interface, so they both can be handled as Lists.

    However, the following is not allowed:

    ArrayList arrayList = new LinkedList();
    

    Although both ArrayList and LinkedList implement List, they are not the same class. They may have similarities by implementing the methods of List, but they are completely separate classes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 119k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think it would make more sense to use a… May 11, 2026 at 11:40 pm
  • Editorial Team
    Editorial Team added an answer In the resin docs it shows an example using regex… May 11, 2026 at 11:40 pm
  • Editorial Team
    Editorial Team added an answer In Xcode 3.2, the "Open Quickly" command (Shift-Control-D) lets you… May 11, 2026 at 11:40 pm

Related Questions

The sentence below is from, The Positive Legacy of C++ and Java by Bruce
In my application, I have the following recurring pattern where I get the feeling
I am querying Active Directory via LDAP (from Java and PHP) to build a
I'm quite new to Java and from Python and PHP, I'm used to default

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.