Java
Programming and Technical
Programming
Program
Which of the following are legal lines of Java code?
1. int w = (int)888.8;
2. byte x = (byte)100L;
3. long y = (byte)100;
4. byte z = (byte)100L;
a) 1 and 2
b) 2 and 3
c) 3 and 4
d) All statements are correct.
Read Solution (Total 16)
-
- d) All statement are correct because we are explicitly doing a type conversion .
- 10 years agoHelpfull: Yes(10) No(0)
- d is correct..... in first one down cast and value becomes 888,100L long value down casting into byte and no problem x=100; in 3 byte can assig to long so no problem last one is also no problem....
so
d is correct - 10 years agoHelpfull: Yes(2) No(0)
- All options are correct.because if we convert from higher to lower then explicit we have to typecast but from lower to higher it is not required to typecast it will automatically typecast but we can mention also,that why all are correct.
- 9 years agoHelpfull: Yes(1) No(0)
- a) 1 and 2
- 10 years agoHelpfull: Yes(0) No(2)
- No third option is wrong because we cant typecast into byte and hold it into long type variable
- 10 years agoHelpfull: Yes(0) No(1)
- a) 1 and 2
- 10 years agoHelpfull: Yes(0) No(0)
- all of option is correct
- 9 years agoHelpfull: Yes(0) No(0)
- a)
1 and 2 - 8 years agoHelpfull: Yes(0) No(0)
- d) is correct
- 8 years agoHelpfull: Yes(0) No(0)
- d is correct
- 8 years agoHelpfull: Yes(0) No(0)
- a is the answer because in other two the long can't be stored in byte
- 7 years agoHelpfull: Yes(0) No(0)
- D
all the statements are correct - 7 years agoHelpfull: Yes(0) No(0)
- a int can covert into int
- 5 years agoHelpfull: Yes(0) No(0)
- a) 1 and 2
- 5 years agoHelpfull: Yes(0) No(0)
- All the statements are correct because we are doing typecasting explicitly .
- 3 years agoHelpfull: Yes(0) No(0)
- d.
All the statements are correct - 3 years agoHelpfull: Yes(0) No(0)
Java Other Question