Advanced Java Programming

Java Collections, I/O Streams, and String Methods

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of the following methods in Map.Entry interface in Java returns the value for the map entry?

  1. getKey()
  2. getValue()
  3. hashCode()
  4. none of these
Question 2 Multiple Choice (Single Answer)

Which of the following methods, declared by Map interface, returns a Set that contains the entries in the Map interface?

  1. containsKey()
  2. containsValue()
  3. entrySet()
  4. none of these
Question 3 Multiple Choice (Single Answer)

In Java, which of the following is implemented by extending AbstractSequentialList class?

  1. AbstractCollection
  2. AbstractList
  3. LinkedList
  4. None of these
Question 4 Multiple Choice (Single Answer)

Which of the following in collection classes in Java implements a set stored in a tree and also extends AbstractSet class?

  1. ArrayList
  2. TreeSet
  3. AbstractSet
  4. HashSet
Question 5 Multiple Choice (Single Answer)

Which of the following methods in ListIterator class returns true if there is a next element otherwise returns false?

  1. add()
  2. hasPrevious()
  3. next()
  4. hasNext()
Question 6 Multiple Choice (Single Answer)

Which of the following methods in SortedMap interface returns the invoking sorted maps comparator?

  1. comparator()
  2. firstKey()
  3. headMap()
  4. none of these
Question 7 Multiple Choice (Single Answer)

Which of the following methods in stack class java returns the element on the top of the stack, but does not remove it?

  1. empty()
  2. peek()
  3. pop()
  4. none of these
Question 8 Multiple Choice (Single Answer)

Which of the following methods in vector class of java returns the capacity of the vector?

  1. addElement()
  2. clone()
  3. capacity()
  4. none of these
Question 9 Multiple Choice (Single Answer)

Which of the following methods in vector class of java returns the string equivalent of the vector?

  1. size()
  2. compareTo()
  3. toString()
  4. none of these
Question 10 Multiple Choice (Single Answer)

Which of the following classes in java allows one or more characters to be returned to the input stream?

  1. PushbackReader
  2. BufferedWriter
  3. BufferedReader
  4. None of these
Question 11 Multiple Choice (Single Answer)

Which of the following in Java counts the number of lines in the input stream?

  1. LineNumberReader
  2. InputStreamReader
  3. FilterReader
  4. None of these
Question 12 Multiple Choice (Single Answer)

Which of the following methods is used in string class of java to extract a single character from a string?

  1. getChars()
  2. charAt()
  3. getBytes()
  4. none of these
Question 13 Multiple Choice (Single Answer)

Which of the following in java contains print() and println() methods?

  1. Reader
  2. Writer
  3. PrintWriter
  4. None of these
Question 14 Multiple Choice (Single Answer)

Which of the following statements about equals() method and '==' operator in java is correct?

  1. The method and the operator perform the same operation.
  2. The method and the operator perform different operations.
  3. There is no equals() method supported by java.
  4. None of these
Question 15 Multiple Choice (Single Answer)

Which of the following methods in string class of java searches for the last occurrence of a character or substring?

  1. indexOf()
  2. substring()
  3. lastIndexOf()
  4. none of these