What will be the output of the following Java code?
int a = 10, b = 20;
if (a < b) { if (b > 15)
{
System.out.println("TRUE");
} else
{
System.out.println("FALSE");
}
}
else
{
System.out.println("NONE");
}
Java - decision making and looping
Quiz
•
Computers
•
University
•
Hard
Sowparnika A
Used 1+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
int a = 10, b = 20;
if (a < b) { if (b > 15)
{
System.out.println("TRUE");
} else
{
System.out.println("FALSE");
}
}
else
{
System.out.println("NONE");
}
TRUE
FALSE
NONE
Compilation error
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The loop executes the block of code if the condition is false.
The loop executes the block of code at least once before checking the condition.
The loop executes the block of code if the condition is true.
The loop condition is checked after executing the block of code.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
int i = 0;
while (i < 3)
{
System.out.println("Hi");
i++;
}
Hi
Hi printed 3 times
Hi printed 4 times
The code results in an infinite loop
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
It terminates the loop and transfers execution to the statement immediately following the loop
It skips the current iteration of the loop and continues with the next iteration.
It causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.
It is used to return a value from a method with a non-void return type.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
switch (day)
{
case 1:
System.out.println("Monday");
break;
case 2: System.out.println("Tuesday");
break;
case 3: System.out.println("Wednesday");
break;
case 4: System.out.println("Thursday");
break;
case 5: System.out.println("Friday");
break;
default: System.out.println("Weekend");
}
Monday
Tuesday
Thursday
Weekend
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
int i = 10;
do
{
System.out.println(i);
i--;
} while (i > 10);
Prints 10
Prints numbers from 10 to 1
No output
Compilation error
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
for (int i = 0, i < 5; i++)
{
}
for (int i = 0; i < 5; i++)
{
}
for i = 1 to 10
{
}
for (int i; i < 5; i++)
{
}
10 questions
CMP128 Java Ch. 05 Methods
Quiz
•
University
9 questions
Passaggio parametri
Quiz
•
University
10 questions
Java Control Flow statements
Quiz
•
University
12 questions
javaquizvivek
Quiz
•
University
15 questions
Java Programming
Quiz
•
University
15 questions
Array Java
Quiz
•
University
10 questions
LOOPS IN C++
Quiz
•
10th Grade - University
10 questions
Briefing Operator Java
Quiz
•
University
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade