issue 117apr 27mmxxvi
est. 2026
delhi/ncr edition
vol. IX · no. 117
PapersAdda
placement intelligence, source-anchored
1,000+ briefs · 24 campuses · 120+ companies
verified offers · sourced from r/developersIndia
razorpay₹65.00 LPA· iit-d · sde-1google₹54.00 LPA· iiit-h · swe-imicrosoft₹49.50 LPA· iit-b · sdeatlassian₹38.00 LPA· nit-w · sde-1amazon₹44.20 LPA· bits-p · sde-1uber₹42.00 LPA· iit-kgp · sde-1razorpay₹65.00 LPA· iit-d · sde-1google₹54.00 LPA· iiit-h · swe-imicrosoft₹49.50 LPA· iit-b · sdeatlassian₹38.00 LPA· nit-w · sde-1amazon₹44.20 LPA· bits-p · sde-1uber₹42.00 LPA· iit-kgp · sde-1
section: Interview Questions / interview questions
08 Jun 2026
placement brief / Interview Questions / interview questions / 08 Jun 2026

Java Generics Interview Questions 2026: 26 Q&A With Code

26 Java generics interview questions for 2026 with full answers, type erasure, bounded types, wildcards, PECS and predict-the-output snippets. Candidate-reported backend and product-company favourites.

on this page§ 09
advertisement

Last Updated: June 2026 | Level: Freshers to Mid-Level | Read Time: ~15 min

Generics are where Java interviews probe whether you understand the type system, not just the syntax. Candidates report that type erasure, wildcards, and the PECS principle are guaranteed for backend and product roles. This guide covers 26 generics questions with full answers and predict-the-output traps. Behaviour reflects the official Oracle Java tutorials; confirm any type-system detail on the JLS.

Pair this with Java Interview Questions 2026 and Java Collections Interview Questions 2026.


Table of Contents

  1. Fundamentals (Q1 to Q9)
  2. Type Erasure (Q10 to Q15)
  3. Wildcards and Bounds (Q16 to Q22)
  4. Advanced (Q23 to Q26)
  5. Predict the Output
  6. Quick Revision Table
  7. Frequently Asked Questions

Fundamentals

Q1. What are generics in Java? Easy

List<String> names = new ArrayList<>();
names.add("Alice");
String s = names.get(0);   // no cast needed

Q2. Why were generics introduced? Easy


Q3. What is a generic class? Medium

class Box<T> {
    private T value;
    void set(T v) { value = v; }
    T get() { return value; }
}

Q4. What is a generic method? Medium

static <T> T firstOf(List<T> list) { return list.get(0); }

Q5. What are the naming conventions for type parameters? Easy


Q6. Can you use primitives as type arguments? Medium


Q7. What is the diamond operator? Easy


Q8. What is a bounded type parameter? Medium


Q9. Can a generic type have multiple bounds? Hard


Type Erasure

Q10. What is type erasure? Hard


Q11. Why can you not use instanceof with a parameterised type? Hard


Q12. Why can you not create a generic array? Hard


Q13. Can two methods differ only by generic type? Hard


Q14. What is a raw type? Medium


Q15. Can you reference a static field of type parameter T? Medium


Wildcards and Bounds

Q16. What is a wildcard in generics? Medium


Q17. What is an upper-bounded wildcard? Medium

double sum(List<? extends Number> nums) {
    double s = 0;
    for (Number n : nums) s += n.doubleValue();
    return s;
}

Q18. What is a lower-bounded wildcard? Medium


Q19. What is the PECS principle? Hard


Q20. What is the difference between List<Object> and List<?>? Hard


Q21. Why can you not add to a List<? extends Number>? Hard


Q22. What is an unbounded wildcard good for? Medium


Advanced

Q23. What is a recursive generic bound? Hard


Q24. Can a generic class extend another generic class? Medium


Q25. What are bridge methods? Hard


Q26. Are generics covariant like arrays? Hard


Predict the Output

Snippet 1

List<Integer> ints = new ArrayList<>();
List<String> strs = new ArrayList<>();
System.out.println(ints.getClass() == strs.getClass());

Output:

true

Why: Type erasure means both are just ArrayList at runtime, so their classes are identical.


Snippet 2

List<? extends Number> list = new ArrayList<Integer>();
// list.add(1);   // compile error
Number n = list.get(0);

Output:

(compiles only without the add line)

Why: An upper-bounded wildcard is read-only for the element type; add is rejected, get returns Number.


Snippet 3

static <T> T pick(T a, T b) { return a; }
System.out.println(pick("x", 5).getClass().getSimpleName());

Output:

Object

Why: With mixed arguments the inferred T is the common supertype Object (technically Serializable & Comparable), so the returned reference type is Object-like; the actual object returned is the String "x".


Quick Revision Table

ConceptKey takeaway
genericscompile-time type safety
type erasureno type info at runtime
no generic arrayerasure prevents it
extends wildcardread (producer)
super wildcardwrite (consumer)
PECSproducer extends, consumer super
invarianceList<Integer> not a List<Object>

Frequently Asked Questions

What generics topic is asked most in Java interviews in 2026?

Candidates report that type erasure, the difference between extends and super wildcards (PECS), and why you cannot create a generic array are the three most repeated Java generics questions.

Is type erasure important for interviews?

Yes. Understanding that generics are a compile-time feature erased at runtime explains many restrictions, like why you cannot use instanceof with a parameterised type or create new T.

What does PECS mean?

Producer Extends, Consumer Super. Use extends when a structure produces values you read, and super when it consumes values you write. It guides correct wildcard use in APIs.

Why are generics invariant when arrays are covariant?

Array covariance defers type checking to runtime and can throw ArrayStoreException, while generic invariance catches the same mismatch at compile time. Wildcards let you opt into controlled variance when you need it.

Why can I not add to a List<? extends Number>?

Because the list might actually be a List<Integer> or List<Double>, and the compiler cannot guarantee the value you add matches the real element type, so it forbids all adds except null.



Confirm any type-system detail on the official Oracle Java documentation before your interview. This guide reflects candidate-reported patterns and public preparation resources as of June 2026.

advertisement
Sources and review notesreviewed 8 Jun 2026
Article-specific sources
Verification window
Page last edited 8 Jun 2026 by Aditya Sharma. A review date records an editorial edit, not a guarantee that every external fact is still current.
Evidence labels

Official notices, candidate reports, offer documents, and editorial practice questions carry different confidence levels. The visible source list lets you inspect the evidence instead of relying on a blanket verification badge.

Verification policy: /editorial-standards/. Found something incorrect? Submit a correction - we respond within 48 hours.

topic cluster

More resources in Interview Questions

Use the category hub to browse similar questions, exam patterns, salary guides, and preparation resources related to this topic.

Open Interview Questions hubBrowse all articles

paid contributor programme

Sat this this year? Share your story, earn ₹500.

First-person experience reports help future candidates prep smarter. We pay verified contributors ₹500 via UPI per accepted story with byline.

Submit your story →

ready to practice?

Take a free timed mock test

Put what you learned into practice. Our mock tests match the 2026 pattern with timer, navigator, reveal, and score breakdown. No signup.

Start free mock test →
related guides
more from PapersAdda
Exam PatternsInfosys Power Programmer Coding 2026: How PP Differs From SP
7 min read
Company Placement PapersAccenture Interview Process 2026: Rounds & Prep
5 min read
Company Placement PapersAccenture Interview Questions 2026 (with Answers for Freshers)
13 min read
Guides & ResourcesAdobe Interview Process 2026: Rounds, OA & Aptitude
10 min read

Share this guide