Test Your Understanding - Introduction To Java - Attempt Review
Test Your Understanding - Introduction To Java - Attempt Review
State Finished
Completed on Sunday, 27 October 2024, 4:07 PM
Quiz
Time taken 6 mins 58 secs
navigation
Marks 7.00/11.00
Grade 63.64 out of 100.00 1 2 3 4
Oops!!! You have scored below 80% ..So Kindly make
Feedback necessary preparations and reattempt.. 5 6 7 8
9 10 11
Question
1.00/1.00
1 Show one page at
a time
What will be the output of the program? Finish review
Given:
10. int x = 0;
12. do {
13. y--;
14. ++x;
Select one:
a. 6,5
b. 5,5
c. 6,6
d. 5,6
Question
0.00/1.00
2
switch(
long
)
.......................................
default:
System.out.println("Hello");
Switch in java works with primitive data types byte, short, char
and int;
wrapper classes like Character, Byte, Short and Integer;
enumerated types (added in java 5) and String class (added in
java 7)
switch([byte])
{
.......................................
default:
System.out.println("Hello");
}
Question
1.00/1.00
3
Select one:
a. 10
b. 9
c. 11
d. 1
The program control will exit the for loop only when the condition
specified in the for loop has failed. Hence, the value of i will be 11.
The correct answer is: 11
Question
1.00/1.00
4
What will happen when the following code is compiled and run in
Java 1.8?
int i = 1, j = -1;
switch (i)
{
case 0, 1: j = 1; /* Line 4 */
case 2: j = 2;
default: j = 0;
}
System.out.println("j = " + j);
Select one:
a. j = 0
b. j = 1
c. j = -1
d. Compilation fails.
One can not specify multiple case labels with commas, as in line
4. Hence compilation error.
The correct answer is: Compilation fails.
Question
0.00/1.00
5
Select one:
a. one two doneone two done
c. done
The correct answer is: one two three two three done
Question
1.00/1.00
6
Which of the following loops will execute the body of loop even
when condition controlling the loop is initially false?
Select one:
a. for
b. do-while
c. while
Question
0.00/1.00
7
class selection_statements {
public static void main(String args[])
int var1 = 5;
int var2 = 6;
if ((var2 = 1) == var1)
System.out.print(var2);
else
System.out.print(++var2);
}
}
Select one:
a. 3
b. 1
c. 2
d. 4
Question
1.00/1.00
8
for
known.
Question
1.00/1.00
9
Select one:
True
False
Question
1.00/1.00
10
The correct answers are: from the innermost switch. , from the
innermost loop
Question
0.00/1.00
11
Select one:
a. int y=11;
b. int y=13;
c. int y=12;
d. int y=10;
Finish review