Question: Let us see an example of explicit downward casting and what can happen main method per the following requirement s : a ) declare a

Let us see an example of explicit downward casting and what can happen main method per the following requirement s :
a) declare a variable 11 of type l ong with a value of 9000000
b) declare another variable 12 of type int with a value of 9000000
c) print both values with the appropriate labels
d) now declare a variable sl1 of type short and cast 11 into it
e) declare another variable sl2 of type short and cast 12 into it
f) print both values again
Save your code in a file called Casting.java. How do you explain the results? What issues might occur if we are not careful?
 Let us see an example of explicit downward casting and what

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!