?
Which of the following automatic type conversion will be possible?
Answer & Solution
Correct Answer:
Option
D
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
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
Join the Discussion
Login to post a comment or share your explanation.
LoginInteger 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.
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...?
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...?
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
and we have a long value ex-10L
automatic conversion will happen like byte ->short ->int ->long->float->double
no. 8 automatic type conversion takes place when size of destination type is larger than source type
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