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

In JDBC 2024-25, which exception is thrown when attempting to use a closed Connection object?

Q.342Medium

What is type erasure in Java Generics?

Q.343Medium

Which statement about wildcard generics (?) is correct?

Q.344Medium

What will happen when you try to create an array of generics? List<String>[] array = new List<String>[10];

Q.345Medium

Consider the code: List<? extends Number> list = new ArrayList<>(); list.add(5); // Will this compile?

Q.346Medium

Which of the following represents a bounded type parameter?

Q.347Medium

What is the difference between List<?> and List<Object>?

Q.348Medium

Consider this generic interface: interface Comparable<T> { int compareTo(T o); } Which class definition correctly implements this?

Q.349Medium

What will be the output? List<Integer> list = new ArrayList<>(); list.add(10); Object obj = list.get(0); System.out.println(obj instanceof Integer);

Q.350Medium

Which of these declarations would NOT cause a compilation warning or error?

Q.351Medium

In the declaration 'List<? extends Number> list', what types can be added to this list at runtime?

Q.352Medium

Which statement correctly uses the lower-bounded wildcard in generics?

Q.353Medium

Which generic declaration would allow storing both String and Integer in the same collection?

Q.354Medium

What does the PECS principle stand for in generics context?

Q.355Medium

In a generic class 'class Box<T extends Comparable<T>>', what constraint is placed on T?

Q.356Medium

Which generic wildcard usage is INCORRECT?

Q.357Medium

What is the relationship between raw types and generics in Java?

Q.358Medium

Consider the method: public static <T> T getFirst(List<T> list) { return list.get(0); } How would you call this method for a List<String>?

Q.359Medium

What is the significance of the '&' operator in generic bounds like '<T extends A & B>'?

Q.360Medium

Which statement about generic type parameters is TRUE?