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

Consider the code: java List<Number> list = new ArrayList<Integer>(); Will this compile?

Q.382Medium

What is the correct output of this code? java List<? extends Number> list = new ArrayList<Integer>(); list.add(5);

Q.383Medium

Which wildcard usage follows the Producer pattern?

Q.384Medium

What does 'covariance' mean in the context of Java Generics?

Q.385Medium

What is the PECS principle in Java Generics?

Q.386Medium

Which of these is a valid generic interface implementation?

Q.387Medium

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

Q.388Medium

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

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

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

Which of the following lambda expressions is invalid?

Q.392Medium

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

Q.393Medium

Which functional interface should be used for a lambda that filters elements?

Q.394Medium

What will this code print? List<Integer> list = Arrays.asList(1, 2, 3, 4, 5); list.forEach(x -> System.out.print(x + " "));

Q.395Medium

Can lambda expressions access local variables from their enclosing scope?

Q.396Medium

Which of the following correctly represents a BiFunction?

Q.397Medium

What is the difference between a lambda expression and an anonymous inner class?

Q.398Medium

Which of the following statements about @FunctionalInterface is true?

Q.399Medium

Can a lambda expression have multiple statements in its body?

Q.400Medium

Which functional interface is best suited for this scenario: method that takes no parameters and returns a random number?