iGET

Java Programming - MCQ Practice Questions

Practice free Java Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.

951 questions | 100% Free

Q.221Easy

When using bounded type parameters with multiple interfaces, what is the correct syntax in Java?

Q.222Easy

What is the primary purpose of lambda expressions introduced in Java 8?

Q.223Easy

Which of the following is a valid lambda expression syntax in Java?

Q.224Easy

What is a functional interface in Java?

Q.225Easy

Which package contains the built-in functional interfaces in Java?

Q.226Easy

What will be the output of the following code? UnaryOperator<Integer> square = x -> x * x; System.out.println(square.apply(5));

Q.227Easy

What is the output of this code? Consumer<String> print = s -> System.out.println(s.toUpperCase()); print.accept("java");

Q.228Easy

In Java 8, a lambda expression can access local variables from its enclosing scope. What is the constraint on these variables?

Q.229Easy

What is the return type of the map() method when used with lambda expressions in Java Streams?

Q.230Easy

Consider the code: List<String> names = Arrays.asList("Raj", "Priya", "Amit"); names.forEach(n -> System.out.println(n)); What does this code do?

Q.231Easy

Which functional interface is used for operations that take no arguments and return a value?

Q.232Easy

What is the primary advantage of using lambda expressions in Java 8+?

Q.233Easy

What will be the output of: List<String> list = Arrays.asList("a", "bb", "ccc"); list.forEach(s -> System.out.print(s.length() + " "));

Q.234Easy

Which functional interface is used for operations that take two arguments and return a single value?

Q.235Easy

What is a method reference (::) in Java?

Q.236Easy

What is the purpose of the @FunctionalInterface annotation in Java?

Q.237Easy

Which stream operation would you use to transform elements from one type to another?

Q.238Easy

Which of the following is a valid lambda expression in Java?

Q.239Easy

A lambda expression can only be used with which type of interface?

Q.240Easy

What is the return type of the lambda expression: (a, b) -> a > b?