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
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following cannot be Type parameterized?
Correct Answer: Option C — Class methods
Detailed Academic Explanation:
Generics in Java are tied to the type of objects, meaning they work at the instance level. Static methods belong to the class itself and are shared across all instances. Since generics are resolved at the object level, type parameters cannot be directly used within static methods. Why the other options are incorrect: Option A: Overloaded Methods Overloaded methods can have different generic type parameters. The compiler can differentiate them based on their method signatures, making generic type parameters valid for overloaded methods. Option B: Generic methods Generic methods explicitly use type parameters, and this is a common and valid usage of generics in Java. Option D: Overriding methods Methods with generic type parameters can be overridden. The overridden method must respect the same type parameter or use a wildcard (?).
💡Key Conceptual Anchor:Generics In Java
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the main purpose of generics in Java?
Correct Answer: Option A — To enable type-safe collections and eliminate type casting
Detailed Academic Explanation:
To enable type-safe collections and eliminate type casting is the correct answer to “What is the main purpose of generics in Java”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which symbol is used to denote a generic type parameter in Java?
Correct Answer: Option D — ``
Detailed Academic Explanation:
`` is the correct answer to “Which symbol is used to denote a generic type parameter in Java”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In a generic class, what does the wildcard ` ` represent?
Correct Answer: Option C — An unknown type
Detailed Academic Explanation:
An unknown type is the correct answer to “In a generic class, what does the wildcard ` ` represent”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the benefit of using generics with collections in Java?
Correct Answer: Option B — It ensures type safety by allowing only specific types of elements
Detailed Academic Explanation:
It ensures type safety by allowing only specific types of elements is the correct answer to “What is the benefit of using generics with collections in Java”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the `E` represent in generic class declarations in Java?
Correct Answer: Option C — Element type
Detailed Academic Explanation:
Element type is the correct answer to “What does the `E` represent in generic class declarations in Java”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java generics, what is the purpose of the ` ` syntax?
Correct Answer: Option D — It restricts the generic type to be a subclass of `SomeClass`
Detailed Academic Explanation:
It restricts the generic type to be a subclass of `SomeClass` is the correct answer to “In Java generics, what is the purpose of the ` ` syntax”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is type erasure in Java generics?
Correct Answer: Option A — The process of removing generic type information at compile time
Detailed Academic Explanation:
The process of removing generic type information at compile time is the correct answer to “What is type erasure in Java generics”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is a generic class in Java?
Correct Answer: Option D — `ArrayList`
Detailed Academic Explanation:
`ArrayList` is the correct answer to “Which of the following is a generic class in Java”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the `? super T` wildcard in Java generics?
Correct Answer: Option C — It allows you to specify that the type must be a superclass of `T`
Detailed Academic Explanation:
It allows you to specify that the type must be a superclass of `T` is the correct answer to “What is the purpose of the `? super T` wildcard in Java generics”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java generics, what is the purpose of the diamond operator (`<>`)?
Correct Answer: Option B — It simplifies the instantiation of generic classes
Detailed Academic Explanation:
It simplifies the instantiation of generic classes is the correct answer to “In Java generics, what is the purpose of the diamond operator (`<>`)”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to define generic methods in Java?
Correct Answer: Option C — ``
Detailed Academic Explanation:
`` is the correct answer to “Which keyword is used to define generic methods in Java”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the ` ` wildcard in a method parameter in Java generics?
Correct Answer: Option D — It allows the method to accept arguments of any type
Detailed Academic Explanation:
It allows the method to accept arguments of any type is the correct answer to “What is the purpose of the ` ` wildcard in a method parameter in Java generics”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the following Java code? List list = new ArrayList<>(); list.add("Hello");
Correct Answer: Option A — Compilation error
Detailed Academic Explanation:
Compilation error is the correct answer to “What is the result of the following Java code? List list = new ArrayList<>(); list.add("Hello");”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, which exception is thrown when there is a type mismatch due to generics?
Correct Answer: Option D — `ClassCastException`
Detailed Academic Explanation:
`ClassCastException` is the correct answer to “In Java, which exception is thrown when there is a type mismatch due to generics”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the `extends` keyword in Java generics?
Correct Answer: Option C — It restricts the generic type to be a subclass or the same as the specified type
Detailed Academic Explanation:
It restricts the generic type to be a subclass or the same as the specified type is the correct answer to “What is the purpose of the `extends` keyword in Java generics”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the term "type parameter" mean in Java generics?
Correct Answer: Option B — A placeholder for a data type
Detailed Academic Explanation:
A placeholder for a data type is the correct answer to “What does the term "type parameter" mean in Java generics”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java generics, what is the purpose of the `? extends T` wildcard?
Correct Answer: Option C — It restricts the generic type to be a subclass or the same as `T`
Detailed Academic Explanation:
It restricts the generic type to be a subclass or the same as `T` is the correct answer to “In Java generics, what is the purpose of the `? extends T` wildcard”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is a valid use of generics in Java?
Correct Answer: Option D — `ArrayList list = new ArrayList();`
Detailed Academic Explanation:
`ArrayList list = new ArrayList();` is the correct answer to “Which of the following is a valid use of generics in Java”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the following Java code? List list = new ArrayList<>(); list.add(new Integer(10));
Correct Answer: Option A — Compilation error
Detailed Academic Explanation:
Compilation error is the correct answer to “What is the result of the following Java code? List list = new ArrayList<>(); list.add(new Integer(10));”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java generics, what is the purpose of the `? super T` wildcard?
Correct Answer: Option D — It allows you to specify that the type must be a superclass of `T`
Detailed Academic Explanation:
It allows you to specify that the type must be a superclass of `T` is the correct answer to “In Java generics, what is the purpose of the `? super T` wildcard”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the primary advantage of using generics in Java?
Correct Answer: Option C — Enhanced type safety and readability of code
Detailed Academic Explanation:
Enhanced type safety and readability of code is the correct answer to “What is the primary advantage of using generics in Java”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is NOT a generic type parameter in Java?
Correct Answer: Option B — None of These
Detailed Academic Explanation:
None of These is the correct answer to “Which of the following is NOT a generic type parameter in Java”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the `get(int index)` method in a generic list in Java?
Correct Answer: Option C — To retrieve an element at the specified index
Detailed Academic Explanation:
To retrieve an element at the specified index is the correct answer to “What is the purpose of the `get(int index)` method in a generic list in Java”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java generics, what is the purpose of the `Pair ` class?
Correct Answer: Option D — To store a pair of values with different types
Detailed Academic Explanation:
To store a pair of values with different types is the correct answer to “In Java generics, what is the purpose of the `Pair ` class”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the term "type erasure" mean in Java generics?
Correct Answer: Option A — The removal of generic type information at compile time
Detailed Academic Explanation:
The removal of generic type information at compile time is the correct answer to “What does the term "type erasure" mean in Java generics”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, which generic class is commonly used for creating key-value pairs?
Correct Answer: Option D — `Map`
Detailed Academic Explanation:
`Map` is the correct answer to “In Java, which generic class is commonly used for creating key-value pairs”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the following Java code? List list = new ArrayList<>(); list.add(new Object());
Correct Answer: Option C — Compilation error
Detailed Academic Explanation:
Compilation error is the correct answer to “What is the result of the following Java code? List list = new ArrayList<>(); list.add(new Object());”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java generics, what is the purpose of the `Enum ` interface?
Correct Answer: Option B — To represent an enumeration type
Detailed Academic Explanation:
To represent an enumeration type is the correct answer to “In Java generics, what is the purpose of the `Enum ` interface”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the term "bounded type parameter" mean in Java generics?
Correct Answer: Option C — A type parameter that has a specific upper or lower bound
Detailed Academic Explanation:
A type parameter that has a specific upper or lower bound is the correct answer to “What does the term "bounded type parameter" mean in Java generics”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, what is the result of the expression `List list = new ArrayList<>();`?
Correct Answer: Option D — It creates a list of strings
Detailed Academic Explanation:
It creates a list of strings is the correct answer to “In Java, what is the result of the expression `List list = new ArrayList<>();`”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these instance cannot be created?
Correct Answer: Option C — Generic type instance
Detailed Academic Explanation:
Generic type instance is the correct answer to “Which of these instance cannot be created”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 33 of 40
★ FPSC
★ PPSC
★ 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)); } }
Correct Answer: Option B — 7.0
Detailed Academic Explanation:
7.0 is the correct answer to “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)); } }”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these data type cannot be type parameterized?
Correct Answer: Option A — Array
Detailed Academic Explanation:
Array is the correct answer to “Which of these data type cannot be type parameterized”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What are generic methods?
Correct Answer: Option C — Generic methods are methods that introduce their own type parameters
Detailed Academic Explanation:
Generic methods are methods that introduce their own type parameters is the correct answer to “What are generic methods”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 36 of 40
★ FPSC
★ PPSC
★ 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()); } }
Correct Answer: Option B — 36
Detailed Academic Explanation:
36 is the correct answer to “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()); } }”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these Exception handlers cannot be type parameterized?
Correct Answer: Option D — all of the mentioned
Detailed Academic Explanation:
all of the mentioned is the correct answer to “Which of these Exception handlers cannot be type parameterized”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 38 of 40
★ FPSC
★ PPSC
★ 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()); } }
Correct Answer: Option D — Hello 36
Detailed Academic Explanation:
Hello 36 is the correct answer to “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()); } }”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these keywords is used to upper bound a wildcard?
Correct Answer: Option C — extends
Detailed Academic Explanation:
extends is the correct answer to “Which of these keywords is used to upper bound a wildcard”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these is wildcard symbol?
Correct Answer: Option A — ?
Detailed Academic Explanation:
? is the correct answer to “Which of these is wildcard symbol”. This question is standard in competitive examination syllabi for Generics In Java.
💡Key Conceptual Anchor:Generics In Java
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡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.