Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions