Quiz Space

Programming Concepts using Java · Quiz 1 · 26 Oct 2025 · September 2025 term

Question 13: Consider the Java code segment given below. From the fol…

Question 13

+5 marksOne correct option

Consider the Java code segment given below.

java
class BookList {
private class Book implements Printable {
private String title;
public Book(String t) {
title = t;
}
public void print() {
System.out.println("Book: " + title);
}
}
private class BookIterator implements Iterable {
private int idx;
public BookIterator() {
idx = -1;
}
public boolean has_next() {
return idx < list.length - 1;
}
public Printable get_next() {
idx++;
return list[idx];
}
}
public Iterable getIterator() {
return new BookIterator();
}
private Book[] list = {
new Book("Java Basics"), new Book("Data Structures"),
new Book("Design Patterns"), new Book("Algorithms"),
new Book("Software Engineering")
};
}
public class TestBooks {
public static void main(String[] args) {
BookList myBooks = new BookList();
Iterable it = myBooks.getIterator();
while(it.has_next()) {
it.get_next().print();
}
}
}

From the following options, identify the appropriate definitions of Iterable and Printable.

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

Correct answer

  • B

Question 13 of 15 in the IIT Madras BS Programming Concepts using Java (Java) Quiz 1 paper sat on 26 Oct 2025, in the September 2025 term (IIT M DIPLOMA AN EXAM QDD2 26 Oct 2025). It carries 5 marks.

More questions from this paper

  1. Q1Consider the following Java program. When the call stack reaches its maximum depth, which method will be at the top of …
  2. Q2Consider the following Java program. What will the output be?
  3. Q3Consider the code given below that searches for a Book in an array. Two Book objects are considered equal if they have …
  4. Q4Consider the Java code given below. Choose the correct option to fill in place of CODE BLOCK so that it produces the gi…
  5. Q5Consider the Java code below. Choose the correct option.
  6. Q6Consider the Java code given below. What will the output be?
  7. Q7Consider the Java code given below. Which of the following statements is FALSE?
  8. Q8Consider the code given below. Identify the appropriate option to fill in the blank at LINE 1, such that the output is:…
  9. Q9Consider the Java code given below. Choose the correct option.
  10. Q10Consider the following Java code. Choose the correct option.
  11. Q11Consider the Java code given below. Choose the correct option.
  12. Q12Consider the Java code given below. Choose the correct option.
  13. Q14Which of the following statements correctly describe static typing and dynamic typing?
  14. Q15Consider the Java program below. Identify the correct option(s) to fill in place of CODE BLOCK so that the output is: P…