
if else conditionals
Quiz
•
Computers
•
4th - 12th Grade
•
Hard
Whizara Teacher
FREE Resource
Enhance your content in a minute
5 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
What will be the output of the following code?
public class Main
{
public static void main(String[] args) {
if(5<4)
System.out.println("Hi");
else
System.out.println("Hello");
}
}
Hi
Hello
Compiled Successfully, No Output.
Compile-time error
2.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
What will be the output of the following code?
public class Main
{
public static void main(String[] args) {
int a = 25;
if(a < 5)
System.out.println("Hi");
if(a < 20)
System.out.println("Hello");
else
System.out.println("Hola");
}
}
Hi
Hello
Hola
Compile-time error
3.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
What does the following code print when x has been set to 187?
if (x < 0)
{
System.out.println("x is negative");
}
else if (x == 0)
{
System.out.println("x is zero");
}
else
{
System.out.println("x is positive");
}
x is zero
x is negative
x is positive
none of the mentioned
4.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
What is the value of grade when the following code executes and score is 80?
if (score >= 90) grade = "A";
if (score >= 80) grade = "B";
if (score >= 70) grade = "C";
if (score >= 60) grade = "D";
else grade = "E";
A
B
C
D
Answer explanation
Each of the if statements will be executed. So grade will be set to B then C and finally D.
5.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
An else statement should be preceded by?
if statement only
else if statement only
either if or else if statement
none of the mentioned
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
10 questions
UNIT 2.4 LOGIC
Quiz
•
10th Grade
10 questions
For loop
Quiz
•
8th Grade
8 questions
Online safety
Quiz
•
5th Grade
10 questions
Activity 1: How well do you know Java?
Quiz
•
9th Grade
10 questions
Artificial Intelligence
Quiz
•
8th Grade
10 questions
8 informatika english
Quiz
•
5th Grade
10 questions
ÔN TẬP CUỐI NĂM 22-23
Quiz
•
5th Grade
9 questions
Test Excel
Quiz
•
10th - 12th Grade
Popular Resources on Wayground
5 questions
This is not a...winter edition (Drawing game)
Quiz
•
1st - 5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
Identify Iconic Christmas Movie Scenes
Interactive video
•
6th - 10th Grade
20 questions
Christmas Trivia
Quiz
•
6th - 8th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
11 questions
How well do you know your Christmas Characters?
Lesson
•
3rd Grade
14 questions
Christmas Trivia
Quiz
•
5th Grade
20 questions
How the Grinch Stole Christmas
Quiz
•
5th Grade
