Java From Beginner To Advanced

0% completed

Previous
Next
Quiz
Question 1
What is the output of the following Java for loop?
for(int i = 0; i < 3; i++) {
    System.out.print(i + " ");
}
A
0 1 2 3
B
1 2 3
C
0 1 2
D
0 1
Question 2
Which loop is guaranteed to execute its body at least once?
A
for loop
B
while loop
C
foreach loop
D
do...while loop
Question 3
Which statement is used to skip the current iteration of a loop in Java?
A
break
B
continue
C
exit
D
skip
Question 4
What will be the output of the following Java for-each loop?
int[] numbers = {2, 4, 6};
for(int num : numbers) {
    if(num == 4) {
        continue;
    }
    System.out.print(num + " ");
}
A
2 4 6
B
2 6
C
4
D
No Output

.....

.....

.....

Like the course? Get enrolled and start learning!
Previous
Next