Generics In Java — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Generics In Java — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
10
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
12 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
10
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress | 0/10 answered
✓ 0 correct
✗ 0 wrong
0% score
🎉 Set complete! All 10 questions answered.
Question 1 of 10
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Question 2 of 10
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these is an correct way making a list that is upper bounded by class Number?
Question 3 of 10
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java program? public class BoxDemo { public static <U> void addBox(U u, java.util.List<Box<U>> boxes) { Box<U> box = new Box<>(); box.set(u); boxes.add(box); } public static <U> void outputBoxes(java.util.List<Box<U>> boxes) { int counter = 0; for (Box<U> box: boxes) { U boxContents = box.get(); System.out.println("Box #" + counter + " contains [" + boxContents.toString() + "]"); counter++; } } public static void main(String[] args) { java.util.ArrayList<Box<Integer>> listOfIntegerBoxes = new java.util.ArrayList<>(); BoxDemo.<Integer>addBox(Integer.valueOf(10), listOfIntegerBoxes); BoxDemo.outputBoxes(listOfIntegerBoxes); } }
Question 4 of 10
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these type parameters is used for a generic methods to return and accept a number?
Question 5 of 10
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following allows us to call generic methods as a normal method?
Question 6 of 10
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java program? import java.util.*; public class genericstack <E> { Stack 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 (); gs.push("Hello"); System.out.println(gs.pop()); } }
Question 7 of 10
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these type parameters is used for a generic methods to return and accept any type of object?
Question 8 of 10
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following keywords are used for lower bounding a wild card?
Question 9 of 10
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is use of wildcards?
Question 10 of 10
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these types cannot be used to initiate a generic type?
✓ Link copied to clipboard
Continue Your Practice
Next Practice Set → 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.