Skip to main content

Generics In Java — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Generics In Java — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

Which of the following cannot be Type parameterized?

Question 2 of 40
★ FPSC ★ PPSC

What is the main purpose of generics in Java?

Question 3 of 40
★ FPSC ★ PPSC

Which symbol is used to denote a generic type parameter in Java?

Question 4 of 40
★ FPSC ★ PPSC

In a generic class, what does the wildcard ` ` represent?

Question 5 of 40
★ FPSC ★ PPSC

What is the benefit of using generics with collections in Java?

Question 6 of 40
★ FPSC ★ PPSC

What does the `E` represent in generic class declarations in Java?

Question 7 of 40
★ FPSC ★ PPSC

In Java generics, what is the purpose of the ` ` syntax?

Question 8 of 40
★ FPSC ★ PPSC

What is type erasure in Java generics?

Question 9 of 40
★ FPSC ★ PPSC

Which of the following is a generic class in Java?

Question 10 of 40
★ FPSC ★ PPSC

What is the purpose of the `? super T` wildcard in Java generics?

Question 11 of 40
★ FPSC ★ PPSC

In Java generics, what is the purpose of the diamond operator (`<>`)?

Question 12 of 40
★ FPSC ★ PPSC

Which keyword is used to define generic methods in Java?

Question 13 of 40
★ FPSC ★ PPSC

What is the purpose of the ` ` wildcard in a method parameter in Java generics?

Question 14 of 40
★ FPSC ★ PPSC

What is the result of the following Java code? List list = new ArrayList<>(); list.add("Hello");

Question 15 of 40
★ FPSC ★ PPSC

In Java, which exception is thrown when there is a type mismatch due to generics?

Question 16 of 40
★ FPSC ★ PPSC

What is the purpose of the `extends` keyword in Java generics?

Question 17 of 40
★ FPSC ★ PPSC

What does the term "type parameter" mean in Java generics?

Question 18 of 40
★ FPSC ★ PPSC

In Java generics, what is the purpose of the `? extends T` wildcard?

Question 19 of 40
★ FPSC ★ PPSC

Which of the following is a valid use of generics in Java?

Question 20 of 40
★ FPSC ★ PPSC

What is the result of the following Java code? List list = new ArrayList<>(); list.add(new Integer(10));

Question 21 of 40
★ FPSC ★ PPSC

In Java generics, what is the purpose of the `? super T` wildcard?

Question 22 of 40
★ FPSC ★ PPSC

What is the primary advantage of using generics in Java?

Question 23 of 40
★ FPSC ★ PPSC

Which of the following is NOT a generic type parameter in Java?

Question 24 of 40
★ FPSC ★ PPSC

What is the purpose of the `get(int index)` method in a generic list in Java?

Question 25 of 40
★ FPSC ★ PPSC

In Java generics, what is the purpose of the `Pair ` class?

Question 26 of 40
★ FPSC ★ PPSC

What does the term "type erasure" mean in Java generics?

Question 27 of 40
★ FPSC ★ PPSC

In Java, which generic class is commonly used for creating key-value pairs?

Question 28 of 40
★ FPSC ★ PPSC

What is the result of the following Java code? List list = new ArrayList<>(); list.add(new Object());

Question 29 of 40
★ FPSC ★ PPSC

In Java generics, what is the purpose of the `Enum ` interface?

Question 30 of 40
★ FPSC ★ PPSC

What does the term "bounded type parameter" mean in Java generics?

Question 31 of 40
★ FPSC ★ PPSC

In Java, what is the result of the expression `List list = new ArrayList<>();`?

Question 32 of 40
★ FPSC ★ PPSC

Which of these instance cannot be created?

Question 33 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? import java.util.*; class Output { public static double sumOfList(List<? extends Number> list) { double s = 0.0; for (Number n : list) s += n.doubleValue(); return s; } public static void main(String args[]) { List<Double> ld = Arrays.asList(1.2, 2.3, 3.5); System.out.println(sumOfList(ld)); } }

Question 34 of 40
★ FPSC ★ PPSC

Which of these data type cannot be type parameterized?

Question 35 of 40
★ FPSC ★ PPSC

What are generic methods?

Question 36 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? import java.util.*; public class genericstack <E> { Stack <E> stk = new Stack <E>(); public void push(E obj) { stk.push(obj); } public E pop() { E obj = stk.pop(); return obj; } } class Output { public static void main(String args[]) { genericstack <Integer> gs = new genericstack<Integer>(); gs.push(36); System.out.println(gs.pop()); } }

Question 37 of 40
★ FPSC ★ PPSC

Which of these Exception handlers cannot be type parameterized?

Question 38 of 40
★ FPSC ★ PPSC

What will be the output of the following Java code? import java.util.*; public class genericstack <E> { Stack <E> stk = new Stack <E>(); public void push(E obj) { stk.push(obj); } public E pop() { E obj = stk.pop(); return obj; } } class Output { public static void main(String args[]) { genericstack <String> gs = new genericstack<String>(); gs.push("Hello"); System.out.print(gs.pop() + " "); genericstack <Integer> gs = new genericstack<Integer>(); gs.push(36); System.out.println(gs.pop()); } }

Question 39 of 40
★ FPSC ★ PPSC

Which of these keywords is used to upper bound a wildcard?

Question 40 of 40
★ FPSC ★ PPSC

Which of these is wildcard symbol?

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →