What is the output of the following code?
```java
int x = 7;
if (x % 2 == 0) {
System.out.print("Even");
} else {
System.out.print("Odd");
}
```
Odd
What is the output of the following code?
```java
int y = 12;
if (y > 10) {
System.out.print("Greater");
} else {
System.out.print("Less");
}
```
Greater
Identify the error in the following code:
```java
int age = 17;
if (age >= 18)
System.out.print("Adult");
else
System.out.print("Minor");
```
Missing curly braces `{}` to define the code blocks for 'if' and 'else'.
What is the output of the following code?
```java
int num = -5;
if (num > 0) {
System.out.print("Positive");
} else {
System.out.print("Not Positive");
}
```
Not Positive
Complete the code to check if a number is positive or negative.
```java
int number = ...;
if (number > 0) {
System.out.print("Positive");
} else {
// Complete this part
}
```
```java
System.out.print("Negative or Zero");
```
What is the output of the following code snippet?
```java
int x = 5;
if (x > 10) {
System.out.print("A");
} else {
System.out.print("B");
}
```
B
Identify the error in the following code:
```java
int age = 20
if (age > 18) {
System.out.println("Adult");
} else {
System.out.println("Not adult");
}
```
Missing semicolon at the end of the first line. (int age = 20;)
What is the output of the following code?
```java
int a = 10;
int b = 5;
if (a < b) {
System.out.println("a is less than b");
} else {
System.out.println("a is not less than b");
}
```
a is not less than b
What is the output of the following code?
```java
int number = 7;
if (number % 2 == 0) {
System.out.println("Even");
} else {
System.out.println("Odd");
}
```
Odd
What is the output of the following code?
```java
int num = 15;
if (num > 10) {
System.out.println("Greater than 10");
} else {
System.out.println("Less than or equal to 10");
}
```
Greater than 10
Define 'if-else statement'.
A control structure that executes one block of code if a condition is true, and another block if the condition is false.
What is a 'condition' in an if-else statement?
A boolean expression that determines which block of code is executed.
Define 'code block'.
A group of zero or more statements enclosed in curly braces `{}`.
Define 'syntax'.
The set of rules that defines the structure of a programming language.
What are the basic steps for executing an if-else statement?
1. Evaluate the condition. 2. If true, execute the 'if' block. 3. If false, execute the 'else' block.