Question: Java Test 26) An object is an instance of a ________. 26) A) data B) class C) method D) program 5 27) Analyze the following

Java Test

26) An object is an instance of a ________.

26) A) data B) class C) method D) program 5

27) Analyze the following code fragments that assign a boolean value to the variable even. Code 1: if (number % 2 = = 0) even = true; else even = false; Code 2: even = (number % 2 = = 0) ? true: false; Code 3: even = number % 2 = = 0;

27) A) Code 3 has a compile error, because you attempt to assign number to even. B) All three are correct, but Code 2 is preferred. C) All three are correct, but Code 1 is preferred. D) Code 2 has a compile error, because you cannot have true and false literals in the conditional expression. E) All three are correct, but Code 3 is preferred.

28) What is the printout of the following switch statement? char ch = 'b'; switch (ch) { case 'a': System.out.print(ch); case 'b': System.out.print(ch); case 'c': System.out.print(ch); case 'd': System.out.print(ch); }

28) A) bcd B) bbb C) bb D) abcd E) b

29) Suppose x=10 and y=10. What is x after evaluating the expression (y > 10) && (x- - > 10)?

29) A) 11 B) 9 C) 10

30) To add 0.01 + 0.02 + ... + 1.00, what order should you use to add the numbers to get better accuracy?

30) A) add 1.00, 0.99, 0.98, ..., 0.02, 0.01 in this order to a sum variable whose initial value is 0. B) add 0.01, 0.02, ..., 1.00 in this order to a sum variable whose initial value is 0.

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!