Explore topic-wise MCQs in Java.

This section includes 11 Mcqs, each offering curated multiple-choice questions to sharpen your Java knowledge and support exam preparation. Choose a topic below to get started.

1.

What does SAM stand for in the context of Functional Interface?

A. Single Ambivalue Method
B. Single Abstract Method
C. Simple Active Markup
D. Simple Abstract Markup
Answer» C. Simple Active Markup
2.

What is the substitute of Rhino javascript engine in Java 8?

A. Nashorn
B. V8
C. Inscript
D. Narcissus
Answer» B. V8
3.

What does Files.lines(Path path) do?

A. It reads all the files at the path specified as a String
B. It reads all the lines from a file as a Stream
C. It reads the filenames at the path specified
D. It counts the number of lines for files at the path specified
Answer» C. It reads the filenames at the path specified
4.

What are the two types of Streams offered by java 8?

A. sequential and parallel
B. sequential and random
C. parallel and random
D. random and synchronized
Answer» B. sequential and random
5.

Which is the new method introduced in java 8 to iterate over a collection?

A. for (String i : StringList)
B. foreach (String i : StringList)
C. StringList.forEach()
D. List.for()
Answer» D. List.for()
6.

What is the return type of lambda expression?

A. String
B. Object
C. void
D. Function
Answer» E.
7.

What is the purpose of BooleanSupplier function interface?

A. represents supplier of Boolean-valued results
B. returns Boolean-valued result
C. There is no such function interface
D. returns null if Boolean is passed as argument
Answer» B. returns Boolean-valued result
8.

Which of the following is not introduced with Java 8?

A. Stream API
B. Serialization
C. Spliterator
D. Lambda Expression
Answer» C. Spliterator
9.

WHAT_DOES_SAM_STAND_FOR_IN_THE_CONTEXT_OF_FUNCTIONAL_INTERFACE??$

A. Single Ambivalue Method
B. Single Abstract Method
C. Simple Active Markup
D. Simple Abstract Markup
Answer» C. Simple Active Markup
10.

What is Optional object used for?

A. Optional is used for optional runtime argument
B. Optional is used for optional spring profile
C. Optional is used to represent null with absent value
D. Optional means it’s not mandatory for method to return object
Answer» D. Optional means it‚Äö√Ñ√∂‚àö√ë‚àö¬•s not mandatory for method to return object
11.

Which feature of java 8 enables us to create a work stealing thread pool using all available processors at its target?

A. workPool
B. newWorkStealingPool
C. threadPool
D. workThreadPool
Answer» C. threadPool