Question 1
Consider the Java code below.
Choose the correct option.
The output is:

generates compilation error because a variable of type cannot refer to an object of type .
The output is:

The output is:


The IIT Madras BS Programming Concepts using Java (Java) Quiz 2 paper sat on 16 Aug 2026, in the May 2026 term, set 1: 15 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.
Consider the Java code below.
Choose the correct option.
The output is:

generates compilation error because a variable of type cannot refer to an object of type .
The output is:

The output is:

Correct answer
The output is:

Consider the following Java code.
Choose the correct option.
The program generates the output:

The program generates the output:

The program generates the output:

The program generates the output:

Correct answer
The program generates the output:

Consider the Java code given below.
Identify the appropriate option to fill in place of such that the output is:




Correct answer

Consider the Java code given below that checks whether a necklace has a mirror pattern of beads (i.e., the sequence of bead colors is the same when viewed from both ends).
Choose the correct option to fill in place of so that the output is:
You may make use of the descriptions of the methods given below. These are methods inside type . : Retrieves and removes the last element of this deque, or returns if this deque is empty. : Retrieves and removes the head of this deque, or returns if this deque is empty.




Correct answer

Consider the Java code given below.
Choose the correct option to be filled in place of so that the output is:




Correct answer

Consider the Java code given below.
Choose the correct option to be filled in place of such that the output is:




Correct answer

Consider two Java files located in two different packages as shown below.
Choose the correct option.
and generate compilation errors.
generates a compilation error, while others compile fine.
, , and generate compilation errors.
Only generates a compilation error.
Correct answer
and generate compilation errors.
Consider the Java code given below.
Identify the statement that throws the when the class is executed as:




Correct answer

Consider the Java code given below.
What will the output be?




Correct answer

Consider the Java code given below.
Choose the correct option.
This program generates the output:

This program generates the output:

This program generates a compilation error because of type cannot invoke method .
and generate compilation errors because static interface methods cannot be accessed using the interface name.
Correct answer
This program generates a compilation error because of type cannot invoke method .
Consider the Java code given below.
After type erasure, which of the following correctly represents the class?




Correct answer

Consider the Java code given below.
Choose the correct option.
will print entries in the order in which they were inserted. will print entries in sorted order of keys.
will print entries in unspecified order. will print entries in sorted order of keys.
will print entries in sorted order of keys. will print entries in insertion order.
Both and will print entries in unspecified order.
Correct answer
will print entries in unspecified order. will print entries in sorted order of keys.
Consider the Java code given below.
Choose the correct option.
This program generates the output:

This program generates the output:

This program generates the output:

This program generates the output:

Correct answer
This program generates the output:

Consider the Java code given below that prints the highest-rated movie among a set of given objects. From among the options, identify the appropriate function header for the function that takes as input an array of objects and prints the highest rating.
Choose the correct option(s) for the function header in .



—
Correct answers

—
Consider the Java code given below that prints the names of trees whose height is between 2 and 5 meters (both inclusive).
Choose the correct option(s) to fill in place of to obtain the right answer.




Correct answers

