iGET

Java Programming - MCQ Practice Questions

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

958 questions | 100% Free

Q.221Easy

Which declaration is valid in Java Generics?

Q.222Easy

In a Spring Boot application, you need to create a generic repository interface that works with any entity type. Which declaration correctly implements this pattern?

Q.223Easy

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

Q.224Easy

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

Q.225Easy

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

Q.226Easy

What is a functional interface in Java?

Q.227Easy

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

Q.228Easy

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

Q.229Easy

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

Q.230Easy

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

Q.231Easy

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

Q.232Easy

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

Q.233Easy

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

Q.234Easy

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

Q.235Easy

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

Q.236Easy

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

Q.237Easy

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

Q.238Easy

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

Q.239Easy

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

Q.240Easy

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