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

The IIT Madras BS Programming Concepts using Java (Java) Quiz 2 paper sat on 12 Apr 2026, in the January 2026 term: 15 questions for 100 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 given below.
What will the output be?




Correct answer

Consider the Java code given below that prints the credit points of courses. From among the options, identify the appropriate function header for the function that takes as input a list of courses and prints their credit points.
Choose the correct option.
—
—
—
—
Correct answer
—
Consider the two Java files given below.
Choose the correct option.
and generate compilation errors.
Only generates compilation error.
and generate compilation errors.
No compilation errors.
Correct answer
Only generates compilation error.
Consider the Java code given below about controlling robot hardware values.
Choose the correct option.
and generate a compilation error because method is already defined with the same signature.
and generate a compilation error because method is already defined with the same signature.
Only generates a compilation error because method is already defined with the same signature.
This program generates output:

Correct answer
Only generates a compilation error because method is already defined with the same signature.
Consider the Java code given below.
Identify the appropriate option to fill in place of such that the output is:
—
—
—
—
Correct answer
—
Consider the code given below.
Choose the correct option.
generates compilation error because method cannot be invoked on .
This code generates the output followed by runtime Error at due to ambiguity in .
This code generates the output:

This code generates the output:

Correct answer
This code generates the output:

Consider the Java code given below.
Choose the correct option to be filled in place of so that the output is:
—
—
—
—
Correct answer
—
The function is defined as: If the specified key is not already associated with a value or is associated with , associates it with the given non-null value. Otherwise, replaces the associated value with the results of the given remapping function, or removes if the result is . Consider the Java code given below.
Choose the correct option.
generates a compilation error due to duplicate keys.
The program generates the output:

The program generates the output:

The program generates the output:

Correct answer
The program generates the output:

Consider the following Java code.
Choose the correct option when the class is executed as:
This code generates output:
This code generates AssertionError:
This code generates AssertionError:
This code generates AssertionError:
Correct answer
This code generates AssertionError:
Consider the following Java code.
What will the output be?
—
—
—
—
Correct answer
—
Consider the Java code given below.
Choose the correct option to fill in place of so that the output is:
Please note the following methods from types and : : Removes the object at the top of this stack and returns it. : Retrieves and removes the head of this deque, or returns null if empty. : Retrieves, but does not remove, the head of this deque, or returns null if empty.




Correct answer

Consider the code given below about an aircraft maintenance record.
What will the output be?




Correct answer

Consider the following Java code that uses chained exceptions in the context of a sports match analysis system.
What can the output of this code be?




Correct answer

Consider the Java code given below that should print the names of individuals whose BMI is between 18 and 25 (both inclusive).
Choose the correct option(s) to fill in place of to obtain the right answer.




Correct answers


Consider the code given below. maps each element of to its frequency of occurrence in list.
Identify the appropriate option(s) to fill in the blank at , such that the output is:




Correct answers

