
Learning-Focused MCQs on Java if-else
Quiz
•
Education
•
11th Grade
•
Medium
Dina Sharawy
Used 3+ times
FREE Resource
Enhance your content
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the main purpose of an if statement in Java?
To repeat a block of code multiple times.
To check a condition and execute code only if it's true.
To execute a block of code without any conditions.
To sort data in a specific order.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will this code print if int x = 10;?
if (x > 5) {
System.out.println("x is greater than 5");
}
x is greater than 5
x is less than 5
Nothing will print
x is equal to 5
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
When would you use an else statement in Java?
To execute code if the if condition is true.
To execute code if the if condition is false.
To stop the program entirely.
To skip over a condition without checking it.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will this code output if int age = 17;?
if (age >= 18) {
System.out.println("Adult"); }
else {
System.out.println("Minor"); }
Adult
Minor
Nothing
Error
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In an if-else ladder, what happens if the first if condition is true?
All following conditions are also checked.
Only the else statement runs.
The program skips all following else if and else conditions.
None of the statements execute.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does this code snippet print if int score = 75;?
if (score >= 90)
{ System.out.println("Grade A");}
else if (score >= 80)
{ System.out.println("Grade B");}
else if (score >= 70)
{System.out.println("Grade C");}
else
{System.out.println("Grade D or below");}
Grade A
Grade B
Grade C
Grade D or below
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following correctly describes nested if statements?
if statements placed one after another.
An if statement with no else condition.
An if statement inside another if or else block.
Multiple else statements in a row.
Create a free account and access millions of resources
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
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?
Similar Resources on Wayground
19 questions
TEST CAPAIAN 1 BAGIAN 2 SETELAH LHBS KELAS XI TPM 1
Quiz
•
11th Grade
20 questions
Safer Internet Day - DRE@M eTwinning project
Quiz
•
7th - 12th Grade
25 questions
MCQ - Coders Premier League
Quiz
•
9th - 12th Grade
16 questions
Computer Concepts Vocabulary
Quiz
•
8th - 12th Grade
25 questions
Digital Security
Quiz
•
7th - 11th Grade
23 questions
Vial Education Quiz
Quiz
•
9th Grade - Professio...
15 questions
(Unit #7) Delmar's Standard Textbook of Electricity: Quiz
Quiz
•
KG - University
15 questions
Chapter 75 ASE Questions
Quiz
•
11th Grade - University
Popular Resources on Wayground
20 questions
Brand Labels
Quiz
•
5th - 12th Grade
10 questions
Ice Breaker Trivia: Food from Around the World
Quiz
•
3rd - 12th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
20 questions
ELA Advisory Review
Quiz
•
7th Grade
15 questions
Subtracting Integers
Quiz
•
7th Grade
22 questions
Adding Integers
Quiz
•
6th Grade
10 questions
Multiplication and Division Unknowns
Quiz
•
3rd Grade
10 questions
Exploring Digital Citizenship Essentials
Interactive video
•
6th - 10th Grade