MCQs Feed | Page - 1

A

Admin • 799.53K Points
Coach

Q. Which method returns the default value without inserting a new key?

  • (A) get()
  • (B) setdefault()
  • (C) pop()
  • (D) None of these

A

Admin • 799.53K Points
Coach

Q. What does the `findAny()` method return?

  • (A) First element of the stream
  • (B) Any element, possibly the first, wrapped in Optional
  • (C) All matching elements
  • (D) Null

A

Admin • 799.53K Points
Coach

Q. What happens if `stream()` is called on a null List?

  • (A) Empty stream is returned
  • (B) NullPointerException is thrown
  • (C) Compilation error
  • (D) All elements are removed

A

Admin • 799.53K Points
Coach

Q. Which method would you use to get the maximum value from a Stream?

  • (A) max()
  • (B) maximum()
  • (C) findMax()
  • (D) collectMax()

A

Admin • 799.53K Points
Coach

Q. What is returned by `reduce()` when no identity is provided and the stream is empty?

  • (A) 0
  • (B) null
  • (C) Optional.empty()
  • (D) IllegalStateException

A

Admin • 799.53K Points
Coach

Q. Which of the following is not a valid intermediate operation?

  • (A) map()
  • (B) filter()
  • (C) collect()
  • (D) limit()

A

Admin • 799.53K Points
Coach

Q. Which method returns true if the stream contains no elements?

  • (A) isEmpty()
  • (B) noneMatch(x -> true)
  • (C) count() == 0
  • (D) Both b and c

A

Admin • 799.53K Points
Coach

Q. Which method is used to create a Stream of primitive ints?

  • (A) IntStream.of()
  • (B) Stream.ofInt()
  • (C) IntStream.stream()
  • (D) Stream.of(int[])

A

Admin • 799.53K Points
Coach

Q. Which of the following types is a primitive specialization of Stream?

  • (A) DoubleList
  • (B) LongList
  • (C) IntStream
  • (D) StringStream

A

Admin • 799.53K Points
Coach

Q. What does `flatMapToInt()` return?

  • (A) Stream<Integer>
  • (B) IntStream
  • (C) DoubleStream
  • (D) LongStream