issue 117apr 27mmxxvi
est. 2017
Sun, 27 Apr 2026
vol. IX · no. 117
PapersAdda
placement intelligence, since 2017
640+ briefs · 24 campuses · by reservation
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

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

9 min read
Interview Questions
Updated: 8 Jun 2026
Aditya Sharma
Aditya's Edit

PapersAdda 2026 Placement Cycle

By Aditya Sharma·Founder & Editor, PapersAdda

What changed in 2026 drives

Mass-recruiter offer letters are flatter for 2026 batch - the 4-5 LPA ASE band has barely budged in three years while inflation eats real wages. Premium tracks (Digital, Pro, Elite, Specialist) are still where the differential lives, and they are entirely test-driven. If you are aiming higher than the default offer, the coding round is not optional pageantry - it is the entire interview.

What I'd actually study for this

  • 01Two solid coding-round answers (1 medium-hard DSA each, with edge-case discussion) > five half-baked ones
  • 02One real project you can defend end-to-end - file paths, design decisions, and what you would change
  • 03One DBMS schema you actually built (not a textbook ER diagram), with at least 3 join-heavy queries written from memory
  • 04Three behavioural STAR stories: failure recovered, conflict handled, ownership taken

Where most candidates trip up

The single biggest mistake is treating company-specific guides as primary prep and DSA as secondary. It is the opposite. Mass recruiters use the test as a filter, but premium tracks at every IT services company use coding to allocate offer band. Spend 70% of prep time on DSA + system fundamentals, 20% on company-specific patterns, 10% on HR rehearsal. Reverse that ratio and you collect the default offer.

Editorial commentary by Aditya Sharma · written for PapersAdda · not generated, not aggregated.

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.

Methodology applied to this articlelast verified 8 Jun 2026
Sources used
Public exam-pattern documents, official recruiter pages, and verified candidate reports on r/developersIndia and LinkedIn.
Verification window
Page last edited 8 Jun 2026 by Aditya Sharma. Numbers and patterns sanity-checked against the most recent 2026 cycle drives we tracked.
What we did NOT do
  • No fabricated salary numbers or success rates. If we quote a range, it's sourced.
  • No noun-substituted templates. This article was not generated by swapping company names in a stock prompt.
  • No paid placements, sponsored coaching links, or affiliate-shilled course pushes.
Verification policy: /editorial-standards/. Found something incorrect? Submit a correction - we respond within 48 hours.

Explore this 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.

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 Articles

More from PapersAdda

Share this guide: