Question 8
Consider the code given below.
interface Navigator { boolean hasNext(); Object next();}abstract class Displayable { public abstract void show();}class BookShelf { private class Book extends Displayable { private String title; public Book(String t) { title = t; } public void show() { System.out.print(title + ", "); } } private class BookIterator implements Navigator { private int index; public BookIterator() { //Constructor } public boolean hasNext() { // Check if there is a next book } public Object next() { // Return the next book
} } public Navigator getNavigator() { return new BookIterator(); } private Book[] books = {new Book("Swami"), new Book("Pyre"), new Book("Palace") };}public class LibraryTest { public static void main(String[] args) { BookShelf shelf = new BookShelf(); Navigator nav = shelf.getNavigator(); while (nav.hasNext()) { ___________________________________; // LINE 1 }
}}Identify the appropriate statement to fill in the blank at LINE 1, such that the output is: Swami, Pyre, Palace,