Examveda
Examveda

Which of the following automatic type conversion will be possible?

A. short to int

B. byte to int

C. int to long

D. All of these

Answer: Option D

Solution(By Examveda Team)

Option A: short to int
Option B: byte to int
Option C: int to long

These conversions are possible because they involve widening conversions where the destination type can accommodate the values of the source type without loss of information.

So, the correct answer is: Option D: All of these

This Question Belongs to Java Program >> Data Types And Variables

Join The Discussion

Comments ( 15 )

  1. Gilna Mol
    Gilna Mol :
    11 months ago

    Bcz the size of long is bigger than int.
    Integer is 4bytes and long is 8bytes.therefore int automatically covert to long.but long is forcely convert to int.Short is shorter of int ie,2 bytes and long is longer of int.

  2. Aditya Vaste
    Aditya Vaste :
    2 years ago

    @Rakesh Sharma What if,
    byte b = 10;
    int i = b;

    Yeah, compiler treat each integral number as "int" by default, for that case your answer is true but in above case , what would you say...?

  3. Aditya Vaste
    Aditya Vaste :
    2 years ago

    @Rakesh Sharma What if,
    byte b = 10;
    int i = b;

    Yeah, compiler treat each integral number as "int" by default, for that case your answer is absolutely correct but for above case , what would you say...?


  4. Ibrahim Khan
    Ibrahim Khan :
    3 years ago

    A, B, C all are correct

  5. Make Smile
    Make Smile :
    4 years ago

    Automatic Type conversion take place when
    1) The two data types are compatible.
    2) When we assign value of a smaller data type to a bigger data type.
    so is
    A, B and C

  6. Rakesh Sharma
    Rakesh Sharma :
    4 years ago

    c is the correct answer because all integer value are by default consider as int there is no byte, short value
    and we have a long value ex-10L

  7. Rupali Dhekane
    Rupali Dhekane :
    5 years ago

    A B and C all 3 are correct answers here
    automatic conversion will happen like byte ->short ->int ->long->float->double

  8. Kiran Andre
    Kiran Andre :
    6 years ago

    how?

  9. Sundar B
    Sundar B :
    6 years ago

    Destination should be greater than source

  10. Jithin C
    Jithin C :
    6 years ago

    why?

  11. Priyabrata Biswal
    Priyabrata Biswal :
    6 years ago

    All three options a,b,c are correct because destination int is comparable and of greater size wrt short and byte.

  12. Arvind Gupta
    Arvind Gupta :
    7 years ago

    A,B,C is correct answer because in these automatic type conversion will be possible, they will not give any error.

  13. Madhvi Jain
    Madhvi Jain :
    7 years ago

    a,b and c options are correct because as per the above ans.
    no. 8 automatic type conversion takes place when size of destination type is larger than source type

  14. Abhijeet Sharma
    Abhijeet Sharma :
    7 years ago

    a,b,c will be answer because Short and Byte can easily covert into Int data type

  15. Ayush Das
    Ayush Das :
    7 years ago

    Given option is wrong. A and B are also true

    Type conversion of below is possible.

    1. byte ->to-> short, char, int, long, double
    2.short ->to-> char, int, long, double
    3.char ->to-> int, long, double
    4.int ->to-> long, float, double
    5.long->to-> double
    6.float ->to->double

Related Questions on Data Types and Variables