Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 loopStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started