Quiz Space

Programming Concepts using Java Quiz 2: 3 August 2025 (May 2025 term)

Question 1

+6 marksOne correct option

Consider the Java code given below.

java
class Printer {
public <T extends Number> void printDetails(T value) { // LINE 1
System.out.println("Number: " + (value.doubleValue() * 3));
}
public <U extends Number> void printDetails(U value) { // LINE 2
System.out.println("Double Number: " + (value.doubleValue() * 6));
}
public <T> void printDetails(T value) { // LINE 3
System.out.println("Value: " + value);
}
}
public class Test {
public static void main(String[] args) {
Printer p = new Printer();
p.printDetails(7);
p.printDetails(3.5);
p.printDetails("Java");
}
}

Choose the correct option.

  1. A
  2. B
  3. C
  4. D

Question 2

+6 marksOne correct option

Consider the following Java code.

java
import java.util.*;
public class SetTest {
public static void main(String[] args) {
LinkedList<Integer> list = new LinkedList<Integer>();
list.add(20);
list.add(30);
list.add(10);
list.add(40);
HashSet<Integer> set1 = new HashSet<Integer>(list);
TreeSet<Integer> set2 = new TreeSet<Integer>(set1);
set2.addAll(set1);
System.out.println(set2);
}
}

Choose the correct option.

  1. A
  2. B
  3. C
  4. D

Question 3

+6 marksOne correct option

Consider the following Java code.

java
class User {
private String username;
private String password;
public User(String u, String p) {
assert u != null; // assert-1
assert p != null; // assert-2
username = u;
password = p;
}
public boolean login() {
assert !username.isEmpty(); // assert-3
assert password.length() >= 6; // assert-4
return username.equals("admin") && password.equals("admin123");
}
}
public class AssertTest {
public static void main(String[] args) {
User user = new User("admin", "");
System.out.println("Login status: " + user.login());
}
}

Identify the first assert statement that throws the AssertionError when the class is executed as: java -ea AssertTest

  1. A
  2. B
  3. C
  4. D

12 more questions in this paper

Sign in with Google — it is free — to see every question with its answer and explanation, practise it in learning mode, or take it as a timed mock test.

More on the Java Quiz 2 3 Aug 2025 paper

The IIT Madras BS Programming Concepts using Java (Java) Quiz 2 paper sat on 3 Aug 2025, in the May 2025 term: 15 questions for 100 marks in 120 minutes. The first 3 questions are below. Sign in with Google — it is free — to see the whole paper with its answers and explanations, in learning mode or as a timed mock test.

FeatureJava Quiz 2 3 Aug 2025 at a glance
TermMay 2025 term
SubjectProgramming Concepts using Java
Course codeBSCS2005
Questions15
Marks100
Duration120 min
MCQ11
MSQ4
Official paperIIT M DEGREE AN EXAM QDB2 03 Aug 2025
Negative markingNo negative marking.
Updated

Same Quiz 2, other subjects

More Java