Site icon DataFlair

Quiz on Type Conversion in Java

quiz on type conversion in java

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

In the realm of programming, data types reign supreme. They act as the very foundation, dictating how variables store and manage information within your Java programs.

These data types serve a critical purpose: ensuring data integrity and enabling efficient operations. But what happens when you encounter a situation where you need to use a value in a way that clashes with its designated data type? Fear not, for type conversion swoops in as your valiant hero!

This interactive quiz is designed to be your training ground for mastering type conversion in Java. Brace yourself to delve into the intricacies of transforming values between different data types, empowering your programs to handle a broader spectrum of scenarios and execute calculations with ease.

By conquering the art of type conversion, you’ll unlock a new level of flexibility and control within your Java code, allowing you to tackle programming challenges with greater finesse. So, are you ready to embark on this exciting quest and become a type conversion champion? Let the quiz commence!

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

    Which of the following data types cannot be used for type conversion ?

    Correct
    Incorrect
  2. Question 2 of 15
    2. Question

     class Convert {

    public static void main ( String args [ ] )

    {

    int i = 10;

    long l = i;

    if( i == l )

    {

    System.out.println(“Type conversion successful”);

    } else {

    System.out.println(“Type Conversion is unsuccessful”);

    }

    }

    }

    What is the output of the program ?

    Correct
    Incorrect
  3. Question 3 of 15
    3. Question

    class Expression {

    public static void main ( String args [ ] )

    {

    int a = 1;

    long b = 2;

    double c = 20.5;

    float d = 1.5;

    System.out.println( (a+b) * (c-d) );

    }

    }

    What will be the output of the program ?

    Correct
    Incorrect
  4. Question 4 of 15
    4. Question

     In which of the following cases Implicit conversion takes place ?

    Correct
    Incorrect
  5. Question 5 of 15
    5. Question

     class Converter {

    public static void main ( String args [ ] )

    {

    String a = ‘a’;

    String b = ‘A’;

    int i = a;

    int j = b;

    System.out.println(a +  “ “ + b );

    }

    }

    What is the value of i and j in the program ?

    Correct
    Incorrect
  6. Question 6 of 15
    6. Question

    class Integer {

    public static void main ( String args [ ] )

    {

    int i = 1;

    char c = (char) i;

    System.out.println(c);

    }

    }

    What is the output of the program ?

    Correct
    Incorrect
  7. Question 7 of 15
    7. Question

     Which of the following is the process of converting a smaller primitive data type into a bigger primitive data type ?

    Correct
    Incorrect
  8. Question 8 of 15
    8. Question

     class Conversion {

    public static void main ( String args [ ] )

    {

    String x = ‘a’;

    int y = x;

    System.out.println(y);

    }

    }

    What is the error in the program ?

    Correct
    Incorrect
  9. Question 9 of 15
    9. Question
    1. Which of the following is the correct syntax to convert a double value to an int value ?

    Correct
    Incorrect
  10. Question 10 of 15
    10. Question

    Which of the following is the smallest of all data types ?

    Correct
    Incorrect
  11. Question 11 of 15
    11. Question

     class Conversion {

    public static void main ( String args [ ] )

    {

    int x = 10;

    double y = (double)x;

    int z;

    System.out.println(y + ” ” +  (z = (int)y) );

    }

    }

    What will be the output of the program ?

    Correct
    Incorrect
  12. Question 12 of 15
    12. Question

    class Byte {

    public static void main ( String args [ ] )

    {

    char a = ‘1’;

    byte b = (byte)a;

    System.out.println(b);

    }

    }

    What is the output of the program ?

    Correct
    Incorrect
  13. Question 13 of 15
    13. Question

    When a data type is automatically converted it is known as ?

    Correct
    Incorrect
  14. Question 14 of 15
    14. Question

    class Long {

    public void display(int i )

    {

    long l = i;

    System.out.println(l);

    }

    }

    class Double {

    public void print ( int i )

    {

    double d = i;

    System.out.println(d);

    }

    }

    class Main {

    public static void main ( String args [  ] )

    {

    Long obj1 = new Long(2);

    Double obj2 = new Double();

    obj2.print(4);

    }

    }

    What is the output of the program ?

    Correct
    Incorrect
  15. Question 15 of 15
    15. Question

     class Type {

    public static void main ( String args [ ] )

    {

    int a = 10 ;

    int b = 5;

    long c = a+b;

    float d = c;

    System.out.println(d);

    }

    }

    What will be the output of the program ?

    Correct
    Incorrect

Summary:

Did you conquer the Java type conversion quiz? Don’t worry if you aced it or encountered challenges – the true reward lies in the gained insights!

This quiz was designed to solidify your understanding of type conversion, a fundamental concept that underpins Java’s functionality. Just like a skilled carpenter relies on a variety of tools, a Java programmer needs to master type conversion to effectively manipulate data. It acts as a bridge, allowing you to seamlessly work with different data types and ensuring smooth program execution.

Whether you’re converting integers to decimals for calculations or strings to numbers for comparisons, type conversion empowers you to make the data work for you. So keep practising and exploring!

The more you delve into the world of Java and type conversion, the more you’ll unlock its potential and become a programming wiz. As you explore further, you’ll discover how type conversion interacts with other Java concepts, like method calls and object creation, making you a more well-rounded Java developer.

Exit mobile version