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
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