Explore topic-wise InterviewSolutions in .

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

1.

On which of these can annotations be used on in Java 8?

Answer»

On which of these can annotations be used on in JAVA 8?
Choose the correct option from below LIST
(1)Local variables
(2)All the options
(3)Generic TYPES
(4)Super classes

Answer:-(2)All the options

2.

Type annotation is used to depict the non-blank string value _________

Answer»

Type ANNOTATION is used to depict the non-blank string value _________
Choose the correct OPTION from below LIST
(1)NotBlank
(2)NotEmpty
(3)NONE of the options
(4)NonBlank

Answer:-(1)NotBlank

3.

Repeating annotations can be added with which of the following declarations?

Answer»

Repeating annotations can be ADDED with which of the following declarations?
Choose the CORRECT OPTION from below list
(A)(1)Declare a REPEATABLE annotation type
(2)Declare the containing annotation type
(b)None of the options
(c)Declare just the repeatable annotation type
(d)(1)Declare a repeatable annotation type
(2)Declare the MODIFIER annotation type

Answer:-(A)(1)Declare a repeatable annotation type
(2)Declare the containing annotation type

4.

Identify the intermediate and terminal operations in the code.

Answer»

Identify the intermediate and terminal operations in the code.
double average = roster
.stream()
.FILTER(p -> p.getGender() == Person.Sex.MALE)
.mapToInt(Person::GETAGE)
.average()
.getAsDouble();
Choose the correct option from below list
(1)Intermediate:average Terminal: filter, mapToInt
(2)Intermediate: filter Terminal: mapToInt, average
(3)Intermediate: filter, mapToInt Terminal: getAsDouble
(4)Intermediate: filter, mapToInt Terminal: average

Answer:-(4)Intermediate: filter, mapToInt Terminal: average

5.

The terminal operation produces another stream as its output.

Answer»

The terminal OPERATION produces another stream as its output.
Choose the CORRECT OPTION from below LIST
(1)True
(2)False

Answer:-(2)False

6.

Optional type validation can be used to substitute runtime validations.

Answer»

Optional type validation can be USED to substitute runtime validations.
Choose the CORRECT option from below list
(1)True
(2)FALSE

Answer:-(2)False

7.

The newly introduced Streams API is available in which package of Java 8?

Answer»

The newly INTRODUCED STREAMS API is AVAILABLE in which PACKAGE of Java 8?
Choose the correct option from below list
(1)java.util.streams
(2)java.io.stream
(3)java.io.streams
(4)java.util.stream

Answer:-(4)java.util.stream

8.

Which of the following is a valid Stream operation type?

Answer»

Which of the following is a valid STREAM operation type?
Choose the correct OPTION from below LIST
(1)NONE of the options
(2)Both the options
(3)Terminal operation
(4)Intermediate operation

Answer:-(2)Both the options

9.

If you wanted to process a stream of names, extract the male names, and store them in a new list, what is the appropriate operation to be used?

Answer»

If you wanted to PROCESS a stream of names, extract the male names, and STORE them in a new list, what is the appropriate operation to be used?
Choose the correct option from below list
(1)Stream.filter
(2)Stream.collect
(3)Stream.reduce
(4)Both Stream.reduce and Stream.collect

Answer:-(2)Stream.collect

10.

Which of these does Stream filter() operates on?

Answer»

Which of these does Stream filter() OPERATES on?
CHOOSE the correct option from below LIST
(1)Interface
(2)Methods
(3)Class
(4)PREDICATE

Answer:-(4)Predicate

11.

Which method is used to connect the consumer to the source in reactive programming?

Answer»

Which method is used to connect the CONSUMER to the source in reactive PROGRAMMING?
Choose the correct option from below LIST
(1)connectTo()
(2)connect()
(3)subscribe()
(4)subscribeTo()

Answer:-(3)subscribe()

12.

Repeating annotations can be retrieved using _________

Answer» REPEATING ANNOTATIONS can be retrieved using _________
CHOOSE the correct option from below list
(1)getAnnotations()
(2)getAnnotationsList()
(3)getAnnotationsByValue()
(4)getAnnotationsByType()

ANSWER:-(4)getAnnotationsByType()
13.

An example of functional interface in Java 8 is __________

Answer»

An example of FUNCTIONAL interface in JAVA 8 is __________
Choose the correct OPTION from below LIST
(1)Both the options
(2)java.util.concurrent.Callable
(3)None of the options
(4)java.lang.Runnable

Answer:-(1)Both the options

14.

Reactive Programming deals with ____________

Answer» REACTIVE Programming DEALS with ____________
Choose the correct option from below LIST
(1)Asynchronous DATA
(2)None of the OPTIONS
(3)Synchronous data
(4)Both the options

Answer:-(1)Asynchronous data
15.

Which package contains Date/Time (JSR 310) API in Java 8?

Answer»

Which package contains Date/Time (JSR 310) API in JAVA 8?
Choose the CORRECT option from below list
(1)java.util.time
(2)java.time
(3)java.util.calendar
(4)java.timedate

Answer:-(2)java.time

16.

Choose the correct output in Java8 Innards

Answer»

Choose the CORRECT output in Java8 Innards
LocalDate date1 = LocalDate.now();
LocalDate date2 = date1.plus(1, ChronoUnit.MONTHS);
PERIOD period = Period.between(date2, date1);
System.out.println("Period: " + period);
Choose the correct option from below LIST
(1)Compilation error
(2)Period: 1
(3)Period: P-1M
(4)Runtime error

Answer:-(3)Period: P-1M

17.

Choose the correct option based on this code segment in Java8 Innards

Answer» CHOOSE the CORRECT option based on this code segment in JAVA8 Innards
import java.util.Optional;
public class App {
public STATIC VOID main(String[] args) {
String[] str = new String[10];
str[5] = null;;
str[4] = "JAVA OPTIONAL CLASS EXAMPLE";
Optional< String> checkNull = Optional.ofNullable(str[5]);
if(checkNull.isPresent()){ // It Checks, value is present or not
String lowercaseString = str[5].toLowerCase();
System.out.print(lowercaseString);
}else
System.out.println("String value is not present");
}
}
Choose the correct output.
(1)String value is not present
(2)Runtime error: Null pointer Exception
(3)Java optional example
(4)Compilation error

Answer:-(1)String value is not present
18.

In Functional Reactive programming, we pull the stream of data.

Answer»

In Functional Reactive programming, we pull the STREAM of data.
Choose the CORRECT option from below list
(1)True
(2)False

Answer:-(2)False

19.

Stream operation iterations are internal over the source of elements.

Answer»

Stream operation ITERATIONS are internal over the source of elements.
Choose the correct option from below list
(1)False
(2)True

Answer:-(1)False

20.

Lambda expressions are based on____________

Answer»

Lambda expressions are BASED on
Please select correct option from below LIST
(1)PROCEDURAL programming
(2)FUNCTIONAL programming
(3)Data programming
(4)All

Answer:-(2)Functional programming

21.

Lambda expressions in Java allow us to treat ___________

Answer»

Lambda expressions in Java allow us to treat ___________
Please select correct option from belowlist
(1)NONE of the OPTIONS
(2)Both the options
(3)Data as code
(4)Code as data

Answer:-(4)Code as data

22.

Which of the following is correct about Java 8 lambda expression?

Answer»

Which of the following is correct about Java 8 lambda expression?
Choose the correct option from below LIST
(1)Both the options
(2)Lambda expression throws a compilation error if a variable is assigned a value the second time.
(3)Using lambda expression, you can refer to the FINAL variable or EFFECTIVELY final variable (which is assigned only once).
(4)None of the options

Answer:-(1)Both the options

23.

Which of the following is the correct lambda expression, which adds two numbers and returns their sum?

Answer»

Which of the following is the correct LAMBDA EXPRESSION, which adds two numbers and RETURNS their sum?
Choose the correct option from below list
(1)(int a, int b) -> a + b;
(2)Both the options
(3)None of the options
(4)(a, b) -> a + b

Answer:-(2)Both the options

24.

Choose the correct option based on this code segment in Java8 Innards Qsn

Answer»

Choose the correct option based on this code SEGMENT in JAVA8 Innards
import java.util.Optional;
PUBLIC class App {
public static void main(String[] args) {
String[] str = new String[10];
str[5] = null;;
str[4] = "JAVA OPTIONAL CLASS EXAMPLE";
Optional< String> checkNull = Optional.ofNullable(str[5]);
if(checkNull.isPresent()){ // It Checks, value is present or not
String lowercaseString = str[5].toLowerCase();
System.out.print(lowercaseString);
}else
System.out.println("String value is not present");
}
}
Choose the correct output.
(1)String value is not present
(2)Runtime error: Null POINTER Exception
(3)Java optional example
(4)Compilation error

Answer:-(1)String value is not present

25.

Choose the correct option based on this code segment

Answer»

Choose the correct OPTION based on this CODE segment
DateTimeFormatter dateFormat=DateTimeFormatter.ISO_DATE;
LocalDate dateOfBirth= LocalDate.of(2015,Month.FEBRUARY,31);
System.out.println(dateFormat.format(dateOfBirth));
What would be the output?
Choose the correct option from below list
(1)PRINTS 2015-02-03
(2)Java DateTimeException
(3)Prints 2015-02-31

Answer:-(2)Java DateTimeException