Site icon DataFlair

Quiz on Autoboxing and Unboxing in Java

quiz on autoboxing and unboxing in java

Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java

Dive into the world of autoboxing and unboxing in Java and see if you can master these fundamental concepts! This interactive quiz is designed to be both informative and engaging.

As you answer questions that test your understanding of how primitive data types seamlessly convert to and from their corresponding wrapper classes, you’ll gain valuable insights into your strengths and weaknesses.

Whether you’re a seasoned Java developer or just starting your programming journey, this quiz serves as a perfect platform to solidify your foundational knowledge of autoboxing and unboxing.

By tackling these challenges and learning from any missteps, you’ll be well on your way to crafting efficient and concise Java code that leverages the power of automatic conversions. So, are you ready to put your autoboxing and unboxing skills to the test? Take the quiz and embark on a rewarding learning experience! Let’s test your knowledge.

Time limit: 0

Quiz Summary

0 of 15 Questions completed

Questions:

Information

You have already completed the quiz before. Hence you can not start it again.

Quiz is loading…

You must sign in or sign up to start the quiz.

You must first complete the following:

Results

Quiz complete. Results are being recorded.

Results

0 of 15 Questions answered correctly

Your time:

Time has elapsed

You have reached 0 of 0 point(s), (0)

Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)

Categories

  1. Not categorized 0%
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  1. Current
  2. Review / Skip
  3. Answered
  4. Correct
  5. Incorrect
  1. Question 1 of 15
    1. Question

     Autoboxing technique is used for which of the following techniques ?

    Correct
    Incorrect
  2. Question 2 of 15
    2. Question

     class Boxing {

    public static void main ( String args [ ] )

    {

    Integer i = 10;

    int j = 5;

    System.out.println(i+j);

    }

    }

    What will be the output of the program ?

    Correct
    Incorrect
  3. Question 3 of 15
    3. Question

    class Function {

    public void change ( Integer i )

    {

    System.out.println(i);

    }

    }

    class Main {

    public static void main ( String args [ ] )

    {

    int i = 10;

    change(i);

    }

    }

    What is the output of the program ?

    Correct
    Incorrect
  4. Question 4 of 15
    4. Question

    Autoboxing in Java eliminates which function in the program ?

    Correct
    Incorrect
  5. Question 5 of 15
    5. Question

    class Casting {

    public static void main ( String args [ ] )

    {

    long l = 12345;

    Byte b = l;

    }

    }

    What is the output of the program ?

    Correct
    Incorrect
  6. Question 6 of 15
    6. Question

     class Main {

    public static void main ( String args [ ] )

    {

    Integer i = new Integer();

    i = 100;

    Short s = i;

    System.out.println(s);

    }

    }

    What will be the output of the program ?

    Correct
    Incorrect
  7. Question 7 of 15
    7. Question

     Which of the following does not have a wrapper class in Java ?

    Correct
    Incorrect
  8. Question 8 of 15
    8. Question

     class AutoBox {

    public void convert ( a )

    {

    Integer i = a:

    System.out.println(“Integer Value is “ + i );

    }

    }

    class Main {

    public static void main ( String args [ ] )

    {

    short a = 2;

    convert(a);

    }

    }

    What is the output of the program ?

    Correct
    Incorrect
  9. Question 9 of 15
    9. Question

    class Box {

    public static void main ( String args [ ] )

    {

    float f = 10;

    System.out.println(f);

    Integer i = f;

    System.out.println(i);

    Float val = f;

    System.out.println(val);

    }

    }

    What is the output of the program ?

    Correct
    Incorrect
  10. Question 10 of 15
    10. Question

    Which of the following are ways to achieve autoboxing in Java ?

    Correct
    Incorrect
  11. Question 11 of 15
    11. Question

     class Example {

    public void value()

    {

    int a = arr.get(1);

    System.out.println(a);

    }

    }

    class Main {

    public static void main ( String args [ ] )

    {

    ArrayList <Integer> arr = new ArrayList();

    arr.add(1);

    arr.add(2);

    arr.add(3);

    System.out.println(arr);

    }

    }

    What is the output of the program ?

    Correct
    Incorrect
  12. Question 12 of 15
    12. Question

     class Unboxing {

    public static void main ( String args [ ] )

    {

    int i = 10;

    String a = i;

    System.out.println(a);

    }

    }

    What is the error in the program ?

    Correct
    Incorrect
  13. Question 13 of 15
    13. Question

    Autoboxing or unboxing is not possible in which of the following ?

    Correct
    Incorrect
  14. Question 14 of 15
    14. Question

    class Demo {

    public static void main ( String args [ ] )

    {

    Queue < Integer > q = new priorityQueue();

    q.add(10);

    q.add(20);

    }

    }

    The given program is an example of which of the following ?

    Correct
    Incorrect
  15. Question 15 of 15
    15. Question

    class Sample {

    public static void main ( String args [ ] )

    {

    Integer x = 50;

    int y =  x;

    System.out.println(y);

    }

    }

    What is the output of the program ?

    Correct
    Incorrect

Summary:

So you’ve taken the Java Autoboxing and Unboxing Quiz and put your skills to the test! This quiz covered key scenarios where autoboxing and unboxing occur, including primitive type assignment to wrapper objects, method parameter passing, and arithmetic operations.

By reviewing both your correct and incorrect answers, you can gain valuable insights into your strengths and weaknesses in this crucial domain. Remember, effective learning is an ongoing process. Explore additional resources beyond the quiz to deepen your understanding. Consider online courses, tutorials, and practice problems to further solidify your grasp of autoboxing and unboxing in Java.

Exit mobile version