AllInfoHub Logo

AllInfoHub – MCQ Practice

Variables and Data Types – Multiple Choice Questions (MCQs)

  1. 25. What will be the result of `(double) 5`?

    • A. 5
    • B. 5
    • C. Error
    • D. 5.0d
  2. 26. What is the difference between `int` and `Integer` in Java?

    • A. `int` is a primitive type
    • B. `Integer` is a wrapper class
    • C. There is no difference
    • D. `Integer` is used for larger numbers
  3. 27. What is autoboxing in Java?

    • A. Automatic conversion of primitive types to their corresponding wrapper objects
    • B. Automatic conversion of wrapper objects to their corresponding primitive types
    • C. Automatic type casting between primitive types
    • D. It is a type of error
  4. 28. What is unboxing in Java?

    • A. Automatic conversion of primitive types to their corresponding wrapper objects
    • B. Automatic conversion of wrapper objects to their corresponding primitive types
    • C. Automatic type casting between reference types
    • D. It is a type of error
  5. 29. Which class is the wrapper class for the primitive type `boolean`?

    • A. Bool
    • B. Boolean
    • C. BoolWrapper
    • D. java.lang.Boolean
  6. 30. Which class is the wrapper class for the primitive type `int`?

    • A. Int
    • B. Integer
    • C. IntWrapper
    • D. java.lang.Integer
  7. 31. Which class is the wrapper class for the primitive type `double`?

    • A. Double
    • B. DoubleWrapper
    • C. Dbl
    • D. java.lang.Double
  8. 32. What is the output of the following code? `int a = 10; Integer b = a; System.out.println(b);`

    • A. 10
    • B. 10
    • C. Error
    • D. null
  9. 33. What is the output of the following code? `Integer x = new Integer(5); int y = x; System.out.println(y);`

    • A. 5
    • B. 5
    • C. Error
    • D. null
  10. 34. What will be the result of `5 / 2` in Java if both operands are integers?

    • A. 2.5
    • B. 2
    • C. 2
    • D. Error
  11. 35. What will be the result of `5.0 / 2` in Java?

    • A. 2.5
    • B. 2
    • C. 2
    • D. Error
  12. 36. What will be the result of `5 / 2.0` in Java?

    • A. 2.5
    • B. 2
    • C. 2
    • D. Error