Quiz Space

Java Quiz 1: 26 October 2025 (September 2025 term)

Question 1

+7 marksOne correct option

Consider the following Java program. When the call stack reaches its maximum depth, which method will be at the top of the call stack?

java
class Demo {
public void alpha(int n) {
if (n > 0) {
beta(n - 1);
}
}
public void beta(int n) {
if (n > 0) {
gamma(n - 1);
}
}
public void gamma(int n) {
if (n > 0) {
gamma(n - 1);
}
}
}
class TestStack {
public static void main(String[] args) {
Demo d = new Demo();
d.alpha(3);
}
}
  1. A

    alpha ()

  2. B

    beta ()

  3. C

    gamma ()

  4. D

    main ()

Question 2

+7 marksOne correct option

Consider the following Java program.

java
public class ArraySquare {
public static int[] square(int[] a){
for(int i = 0; i < a.length; i++){
a[i] = a[i] * a[i];
}
return a;
}
public static void main(String[] args) {
int[] arr = {2,3,4};
int[] b = square(arr);
System.out.println(arr[1] + b[2]);
}
}

What will the output be?

  1. A

    21

  2. B

    28

  3. C

    25

  4. D

    16

Question 3

+7 marksOne correct option

Consider the code given below that searches for a Book in an array. Two Book objects are considered equal if they have the same title and isbn. The equals method needs to be overridden so that the search works correctly.

java
class Book {
private String title;
private String isbn;
//constructor to initialize the instance variables
public boolean equals(Object obj) {
// CODE BLOCK
}
}
public class Test {
public static void main(String[] args) {
Book[] library = {
new Book("Effective Java", "111"),
new Book("Clean Code", "222"),
new Book("Design Patterns", "333")
};
Book target = new Book("Clean Code", "222");
boolean found = false;
for (int i = 0; i < library.length; i++) {
if (library[i].equals(target)) {
found = true;
break;
}
}
if (found)
System.out.println("Book Found");
else
System.out.println("Book Not Found");
}
}

Choose the correct option to fill in place of CODE BLOCK so that the output is:

Book Found

  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 1 26 Oct 2025 paper

The IIT Madras BS Programming Concepts using Java (Java) Quiz 1 paper sat on 26 Oct 2025, in the September 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 1 26 Oct 2025 at a glance
TermSeptember 2025 term
SubjectProgramming Concepts using Java
Course codeBSCS2005
Questions15
Marks100
Duration120 min
MCQ13
MSQ2
Official paperIIT M DIPLOMA AN EXAM QDD2 26 Oct 2025
Negative markingNo negative marking.
Updated

Same Quiz 1, other subjects

More Java