Question: 1. Explain why we need to use a type cast in this Java code, when we wouldn't have to in C++. int myNum; long anotherNum;

1. Explain why we need to use a type cast in this Java code, when we wouldn't have to in C++.

int myNum; long anotherNum; myNum = (int)anotherNum + 1;

2. Explain the difference between primitive type variables and class type variables. After you explain, declare two variables: one primitive and one class type.

3. In addition to single line (//) and multi line (/* */) comments (that we had in C++), Java adds a third type. What is it called, how does it look different, and why would you use it?

4. What happens if you forget to put System.exit(0); at the end of a program that uses dialog boxes? Is it safer then, and a best practice, to put it at the end of every Java program? Why or why not?

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!