What is a wrapper class in Java?

Java MCQ: What is a wrapper class in Java?

a) A class that converts primitive data types into objects
b) A class that handles arrays
c) A class that wraps other classes
d) A class that stores collections

Answer:

a) A class that converts primitive data types into objects

Explanation:

A wrapper class in Java converts primitive data types into objects. This allows primitive values to be used where objects are required, such as in collections. For example, the Integer class wraps the primitive type int.

Understanding wrapper classes is important for working with Java collections and generics, where objects are often required.

Reference links:

https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top