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.781Hard

Consider this declaration: public static <T> List<T> createList(). Which statement about type inference is correct?

Q.782Hard

What is the difference between List<Object> and List<?> in practical usage?

Q.783Hard

What is the compiled bytecode signature of this generic method? public <T extends Comparable<T>> T findMin(T[] arr)

Q.784Hard

Which statement about generic array creation is correct?

Q.785Hard

What output will this produce? java List<? super Integer> list = new ArrayList<Number>(); list.add(5); Integer val = (Integer) list.get(0);

Q.786Hard

Which Java feature was introduced specifically to support generics compilation?

Q.787Medium

What is the runtime class object for this generic variable? java List<String> list = new ArrayList<String>(); Class<?> c = list.getClass();

Q.788Medium

A developer creates a generic method that accepts a collection of numbers and calculates their sum. Which type parameter declaration would be most appropriate for this scenario?

Q.789Easy

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.790Medium

A utility class needs a method that accepts a List containing elements that are instances of a specific class or its subclasses. Which wildcard notation should be used?

Q.791Easy

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

Q.792Hard

A method processes collections where items need to be added back to the same collection type. Which wildcard approach ensures type safety for write operations?

Q.793Medium

In a microservices architecture, you're designing a Response wrapper class that should work with any data type, including primitives when boxed. Which implementation is correct?

Q.794Easy

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

Q.795Easy

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

Q.796Easy

What is a functional interface in Java?

Q.797Easy

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

Q.798Easy

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

Q.799Medium

Which of the following lambda expressions is invalid?

Q.800Medium

What is the type of the following lambda expression: x -> x.length()?