SE100 Midterm1 Fall2017 Sample
SE100 Midterm1 Fall2017 Sample
a. Work correctly
b. Generate run-time error
c. Generate logic error
d. Generate syntax error
a. goodbye goodbye
b. goodbye Goodbye
c. Goodbye goodbye
d. Goodbye Goodbye
a. x will be 10
b. x will be 12.5
c. x will be 13
d. The code will not compile
11) Note that the ASCII for character A is 65. What is the output of the following code:
char ch = 'A';
System.out.println (++ch);
a. b b. A c. B d. a
12) The expression "Java" + 1 + 2 + 3 evaluates to___________________.
a) Java123
b) Java6
c) Java 123
d) java 123
14) Given: int j = 12, k = 12, m = 7; what is the result of evaluating j%m%k*2:
a. 2 b. 5 c. 10 d. 12
15) Suppose
int x = 1;
x /= 2;
What is x?
a. 0 b. 1 c. 2 d. Illegal expression
a. area25.5area=
b. area area= 25.5
c. areaarea=25.5
d. area
area=25.5
17) Given int x = 3 and double y = 3.1; what is the result of x after x += (int)y * x;
a. Syntax error!
b. 12
c. 12.3
d. 9
18) Note that the ASCII code for character A is 65. If char c = (char) 65. Then, System.out.print(c);
will print.
a. B b. A c. 65 d. Illegal expression
21) Which of the following lines allows a programmer to use the Scanner class in a Java program?
a. import java.util.Scanner;
b. using Scanner;
c. include java.util.Scanner;
d. All of the above
23) Which of the following assignment statement is correct to assign Unicode value to ch variable?
a. char ch = ‘a’;
b. char ch = "a";
c. char ch = '\ua';
d. char ch = ‘\u0041’;