[ Team LiB ] Page 112

[ Team LiB ] Review Questions 3.10 Which statements are true? Select the three correct answers. a. The result of the expression (1 + 2 + “3″) would be the string “33″. b. The result of the expression (”1″ + 2 + 3) would be the string “15″. c. The result of the expression (4 + 1.0f) would be the float value 5.0f. d. The result of the expression (10/9) would be the int value 1. e. The result of the expression (’a’ + 1) would be the char value ‘b’. 3.11 What happens when you try to compile and run the following program? public class Prog1 { public static void main(String[] args) { int k = 1; int i = ++k + k++ + + k; System.out.println(i); } } Select the one correct answer. a. The program will not compile. The compiler will complain about the expression ++k + k++ + + k. b. The program will compile and will print the value 3 when run. c. The program will compile and will print the value 4 when run. d. The program will compile and will print the value 7 when run. e. The program will compile and will print the value 8 when run. 3.12 Which is the first incorrect line that will cause a compile time error in the following program? public class MyClass { public static void main(String[] args) { char c; int i; c = ‘a’; // (1) i = c; // (2) i++; // (3) c = i; // (4) Page 113
Note: If you are looking for cheap and quality provider to host and run your java application check Astra java hosting services

Comments are closed.