ExamVeda
Login
Home
Data Types and Variables
?

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
Examveda
Question posted by Examveda
Community

Join the Discussion

15 Comments
Gilna Mol
Gilna Mol 3 years 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.
Aditya Vaste
Aditya Vaste 5 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...?
Aditya Vaste
Aditya Vaste 5 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...?


Ibrahim Khan
Ibrahim Khan 6 years ago
A, B, C all are correct
Make Smile
Make Smile 7 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
Rakesh Sharma
Rakesh Sharma 7 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
Rupali Dhekane
Rupali Dhekane 7 years ago
A B and C all 3 are correct answers here
automatic conversion will happen like byte ->short ->int ->long->float->double
Kiran Andre
Kiran Andre 8 years ago
how?
Sundar B
Sundar B 8 years ago
Destination should be greater than source
Jithin C
Jithin C 8 years ago
why?
Priyabrata Biswal
Priyabrata Biswal 8 years ago
All three options a,b,c are correct because destination int is comparable and of greater size wrt short and byte.
Arvind Gupta
Arvind Gupta 9 years ago
A,B,C is correct answer because in these automatic type conversion will be possible, they will not give any error.
Madhvi Jain
Madhvi Jain 9 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
Abhijeet Sharma
Abhijeet Sharma 9 years ago
a,b,c will be answer because Short and Byte can easily covert into Int data type
Ayush Das
Ayush Das 10 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