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 intOption 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
Comments ( 15 )
Related Questions on Data Types and Variables
What is the maximum value that can be stored in a byte variable in Java?
A. 127
B. 255
C. 32767
D. 64
What is the default value of an int variable in Java if it's not explicitly initialized?
A. 0
B. 1
C. -1
D. Null
Which of the following is not a valid identifier for a Java variable?
A. my_var
B. _myVar
C. 3rdVar
D. $var
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.
@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...?
@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...?
A, B, C all are correct
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
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
A B and C all 3 are correct answers here
automatic conversion will happen like byte ->short ->int ->long->float->double
how?
Destination should be greater than source
why?
All three options a,b,c are correct because destination int is comparable and of greater size wrt short and byte.
A,B,C is correct answer because in these automatic type conversion will be possible, they will not give any error.
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
a,b,c will be answer because Short and Byte can easily covert into Int data type
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