Problem 3 (R4.16)
Note: Appendix E of the textbook contains a chart showing the order of precedence of Java operators.
What are the values of the following expressions? In each line assume that
double x = 2.5;
double y = -1.5;
int m = 18;
int n = 4;
String s = “Hello”;
String t = “World”;
- x + n * y – ( x + n ) * y
- m / n + m % n
- 5 * x – n / 5
- Math.sqrt(Math.sqrt(n))
- (int) Math.round(x)
- (int) Math.round(x) + (int) Math.round(y)
- s + t
- s + n
- 1 – ( 1 – ( 1 – ( 1 – ( 1 – n ))))
- s.substring(1,3)
- s.length() + t.length()
No comments:
Post a Comment