What is the output of this code?
```java
int x = 5;
if (x > 0) {
System.out.println("Positive");
} else {
System.out.println("Negative");
}
Java Summative Assessment 2
Quiz
•
Computers
•
12th Grade
•
Easy
chrisbenedict sevilleno
Used 1+ times
FREE Resource
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of this code?
```java
int x = 5;
if (x > 0) {
System.out.println("Positive");
} else {
System.out.println("Negative");
}
Positive
Negative
Nothing
Error
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which symbol is used for the "not equal to" comparison in an if statement?
`!=`
`==`
`>`
`<>`
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will this code print?
```java
int age = 16;
if (age >= 18) {
System.out.println("Adult");
} else {
System.out.println("Minor");
}
```
Adult
Minor
Nothing
Error
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct syntax for an if-else statement?
`if condition { } else { }`
`if (condition) { } else { }`
`if [condition] { } else { }`
`if condition then { } else { }`
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will this code output?
```java
int num = 10;
if (num % 2 == 0) {
System.out.println("Even");
} else {
System.out.println("Odd");
}
Even
Odd
Nothing
Error
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does this code print?
```java
boolean isSunny = false;
if (isSunny) {
System.out.println("Go outside");
} else {
System.out.println("Stay inside");
}
Go outside
Stay inside
Nothing
Error
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is missing in this code to make it compile?
```java int x = 7;
if x > 5 {
System.out.println("Big");
}
```
Parentheses around the condition
Curly braces
Semicolon after the condition
A variable declaration
15 questions
Array
Quiz
•
10th - 12th Grade
18 questions
STATIC KEYWORD IN JAVA
Quiz
•
9th - 12th Grade
15 questions
Unit 2 Inheritance in Java
Quiz
•
12th Grade - University
15 questions
Basics in Java
Quiz
•
9th - 12th Grade
16 questions
Arithmetic Types Declare Initialize Relation Logical Ops
Quiz
•
9th Grade - University
19 questions
TechfestQuiz 2024
Quiz
•
9th - 12th Grade
19 questions
Java Method
Quiz
•
12th Grade
15 questions
Java Strings and Math Quiz
Quiz
•
12th Grade
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
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
20 questions
Taxes
Quiz
•
9th - 12th Grade
17 questions
Parts of Speech
Quiz
•
7th - 12th Grade
20 questions
Chapter 3 - Making a Good Impression
Quiz
•
9th - 12th Grade
20 questions
Inequalities Graphing
Quiz
•
9th - 12th Grade
10 questions
Identifying equations
Quiz
•
KG - University