
Understanding If Statements in Java
Quiz
•
Computers
•
5th Grade
•
Practice Problem
•
Hard
Mohid Atif
FREE Resource
Enhance your content in a minute
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct syntax for an if statement in Java?
if (condition) {}
if condition: {}
if [condition] {}
if condition {}
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is used to compare two strings in Java for equality within an if statement?
==
equals()
compareTo()
Both A and B
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will the following code snippet print? ```java if (5 > 3) { System.out.println("Five is greater than three."); } ```
Five is greater than three.
Error
Nothing
5 > 3
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can you correctly check if a string `name` equals "John" in an if statement?
if (name == "John")
if (name.equals("John"))
if ("John".equals(name))
B and C are correct
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? ```java String a = "Hello"; String b = "hello"; if (a.equals(b)) { System.out.println("Equal"); } else { System.out.println("Not Equal"); } ```
Error
Equal
Not Equal
None of the above
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In Java, which operator is used to check if two values are NOT equal in an if statement?
!=
==
<=
>=
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the following code snippet output? ```java int number = 10; if (number % 2 == 0) { System.out.println("Even"); } else { System.out.println("Odd"); } ```
Odd
Even
Error
None of the above
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
Nowe technologie
Quiz
•
1st - 6th Grade
18 questions
G 6 Unit 5
Quiz
•
5th Grade
10 questions
Computer Network
Quiz
•
5th Grade
10 questions
Internet Services
Quiz
•
5th - 8th Grade
20 questions
Systemy Operacyjne - Sem 1
Quiz
•
1st - 6th Grade
10 questions
Quiz
Quiz
•
4th - 6th Grade
15 questions
computer language
Quiz
•
5th - 10th Grade
10 questions
Email Quiz - PWHS
Quiz
•
1st - 12th Grade
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
