Question
devry cis355a week 1 quiz Latest 2016 may
1. Question : (TCOs 1–8) _____ is interpreted.
Pascal
Java
C++
Ada
C
Question 2. Question : (TCOs 1–8) What is the printout of the following code?
double x = 5.5;
int y = (int)x;
System.out.println("x is " + x + " and y is " + y);
x is 5.5 and y is 5.0
x is 5.5 and y is 5
x is 5 and y is 6
x is 6 and y is 6
x is 6.0 and y is 6.0
Question 3. Question : (TCOs 1–8) What is the value of (double)(5/2)?
2.0
2
3.0
2.5
3
Question 4. Question : (TCOs 1–8) Suppose x=10 and y=10, what is x after evaluating the expression (y >= 10) || (x++ > 10)?
9
11
10
Illegal expression
Question 5. Question : (TCOs 1–8) What is y after the following switch statement is executed?
x = 3;
switch (x + 3) {
case 6: y = 0;
case 7: y = 1;
default: y += 1;
}
1
4
2
3
Question 6. Question : (TCOs 1–8) Analyze the following statement.
double sum = 0;
for (double d = 0; d<10;) {
d += 0.1;
sum += sum + d;
}
The program compiles and runs fine.
The program runs in an infinite loop because d<10 would always be true.
The program has a compile error because the control variable in the for loop cannot be of the double type.
The program has a compile error because the adjustment is missing in the for
loop.
Question 7. Question : (TCOs 1–8) What is the value in count after the following loop is executed?
int count = 0;
do {
System.out.println("Welcome to Java");
} while (count++ < 9);
System.out.println(count);
10
9
0
8
11
Question 8. Question : (char)('a' + Math.random() * ('z' - 'a' + 1)) returns a random character _____
between 'b' and 'z'.
between 'a' and 'y'.
between 'a' and 'z'.
between 'b' and 'y'.
Question 9. Question : (Tricky) What is the output of the following code?
public class Test {
public static void main(String[ ] args) {
int[ ] x = {120, 200, 016};
for (int i = 0; i < x.length; i++)
System.out.print(x[i] + " ");
}
}
120 200 16
120 200 20
120 200 14
016 is a compile error. It should be written as 16.
Question 10. Question : Analyze the following code.
public class Test {
public static void main(String[ ] args) {
int[ ] x = new int[5];
int i;
for (i = 0; i < x.length; i++)
x[i] = i;
System.out.println(x[i]);
}
}
The program displays 4.
The program displays 0 1 2 3 4.
The program has a runtime error because the last statement in the main method causes ArrayIndexOutOfBoundsException.
The program has a compile error because i is not defined in the last statement in the main method.
Answered
Other
/
Other
16 Jun 2016
Answers (1)
Devry CIS355A/ Devry CIS355A Week 1 Quiz Latest (2016)
Answer Attachments
1 attachments —