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

Java 1. Practice the following scenarios in a Java program: a. Declare

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

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!