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
What is the correct output of this code? java List<? extends Number> list = new ArrayList<Integer>(); list.add(5);
Which wildcard usage follows the Producer pattern?
What does 'covariance' mean in the context of Java Generics?
What is the PECS principle in Java Generics?
Which of these is a valid generic interface implementation?
What is the runtime class object for this generic variable? java List<String> list = new ArrayList<String>(); Class<?> c = list.getClass();
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?
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?
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?