
Java - decision making and looping
Authored by Sowparnika A
Computers
University
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
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");
}
TRUE
FALSE
NONE
Compilation error
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How does a while loop start?
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
What does the following code print?
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
What is the use of the break statement in loops?
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
What will the following switch statement output for int day = 4; ?
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
What is the output of the following code ?
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
Which of the following for loop declarations is valid in Java?
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++)
{
}
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
11 questions
Video Watermaking
Quiz
•
University
10 questions
JSPS Competition Hackathon - Scratch Language - Grade 1
Quiz
•
2nd Grade - University
10 questions
Microcontroller
Quiz
•
11th Grade - University
14 questions
Input, output and storage de
Quiz
•
8th Grade - Professio...
15 questions
IT 209
Quiz
•
University
15 questions
Assessment 08
Quiz
•
University
10 questions
1ª Recuperação - 3° Trim. - Pensamento Computacional - 9º ano
Quiz
•
9th Grade - University
12 questions
ICT450-TOPIC 1
Quiz
•
University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade