MiniTest 230304
MiniTest 230304
MiniTest 230304
Questions:
(ii) Are the following statements correct? If so, show the output.
System.out.println(“the output for 25/4 is “ + 25 / 4);
System.out.println(“the output for 25/4.0 is “ + 25 / 4.0);
4. (i) How would you write the following arithmetic expression in Java?
4 3 + d (2 + a )
− 9(a + bc) +
3(r + 34) a + bd
(ii) Can Java run on any machine? What is needed to run Java on a computer? What are the
input and output of a Java compiler?
5. Assume that int a = 1 and double d = 1.0, and that each expression is independent. What
are the results of the following expressions?
a) a = 46 / 9;
b) a = 46 % 9 + 4 * 4 – 2;
c) a = 45 + 43 % 5 * (23 * 3 % 2);
d) a = 45 + 45 * 50 % a--;
e) a = 45 + 1 +45 * 50 % (++a + 1);
f) d += 1.5 * 3 + (++d);
g) d -= 1.5 * 3 + d++;
h) a %= 3 / a + 3;
Page 1 of 2
Mini test Engineering Software 1
10. (i) The keyword(s) that every types method must have is:
a) void
b) return
c) break
d) public static void
(ii) If we have two integers to return from a method, we can use:
a) an object as a parameter
b) an object as a return value
c) two parameters
d) answer (a) or (b)
Page 2 of 2