Question: Java 1. Practice the following scenarios in a Java program: a. Declare a variable x of type int, and assign the value 130 to it.
Java

1. Practice the following scenarios in a Java program: a. Declare a variable x of type int, and assign the value 130 to it. Now declare another variable y of type byte and try to assign the value of x to it (i.e. y=x; ). See what happens? Is this upcasting or down casting? b. Try to lower the value of x to less than 127 . Does it work? Why? c. Change the value of x back to 130. Try to use explicit down casting to assign the value of x to y( i.e. y=( byte )xi ) d. Print the value of y, is it 130 ? If not, then why not? Why the value is what it is? 2. Write a program that prints only odd numbers between 1 and 99 using a continue statement in the loop
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
