Java Reference
In-Depth Information
15. If necessary, insert parentheses so that each numeric expression results in the
value indicated on the left side of the assignment operator (=).
a. 33 = 3 * 6 - 3 + 2 + 6 * 4 - 4 / Math.pow(2,1);
b. 22 = 7 * 3 + Math.pow(4,2) - 3 / 13;
c. 1 = 25 % 6 - 18 + 6 * 3;
d. 5.0 = 3.0/2.0 + 0.5 + Math.pow(3.0,1.0);
16. Assume each of the following values has been entered by the user and stored
as a String. Write a line of code to convert each variable to an appropriate
primitive data type.
a. interestRate
b. age
c. pi
d. distanceToMoon
e. numberOfStudents
17. Describe the differences between JOptionPane message boxes and
JOptionPane input boxes.
18. Describe the difference between the getText() method and the setText()
method. Give examples of each, including components, arguments, and
results.
19. Choose any two numbers and write a formula using each of the arithmetic
operators with those two numbers. Solve each formula the way Java would
solve it.
20. List five boolean expressions using the relational or conditional operators.
Use a variable as one part of your expression. Then, list two variable values
that would make your expression true and two that would make your
expression false.
21. Write a paragraph describing a situation in which casting might be appro-
priate. Give examples.
22. Define what is meant by a loss of precision.
23. What does it mean to say that Java is a strongly typed language?
24. Describe the difference between primitive data types and reference data
types, and give examples of each.
25. List a variable in the Body Mass Index Calculator program that must have
class level scope, and explain why.
Search WWH ::




Custom Search