## Questions and Answers

What is the result of the AND operation between 'true' and 'false'?

false

For the XOR operation, when does it return 'false'?

When both operands are true

What is the result of applying the NOT operator twice (!!) on 'true'?

true

What is the perimeter of a rectangle with length 15 and breadth 27?

Signup and view all the answers

In a rectangle with length 15 and breadth 27, what is the area?

Signup and view all the answers

Which of the following is a unary operator in Java?

Signup and view all the answers

What is the purpose of the modulo operator (%)?

Signup and view all the answers

Which of the following is a ternary operator in Java?

Signup and view all the answers

What is the result of the expression `5 > 3 && 2 < 4`

?

Signup and view all the answers

Which of the following relational operators checks for equality?

Signup and view all the answers

What is the result of the expression `!false`

?

Signup and view all the answers

## Study Notes

### Binary Operators

- The binary operator AND (&) evaluates to true only when both operands have a true value.
- The binary operator OR (|) evaluates to true except when both operands are false.
- The binary operator XOR (^) returns true except when both operands have the same value.

### Unary Operators

- The unary NOT (!) operator is complimentary, switching true to false and false to true.

### Operators in Java

- Operators are symbols that carry out mathematical or logical functions on an operand or operands.
- Types of operators in Java:
- Unary Operators: have only one operand, e.g., bitwise complement (~), negation (-), increment (++) and decrement (--).
- Binary Operators: have exactly two operands, e.g., arithmetic, relational, and logical operators.
- Ternary Operators: have at most three operands, e.g., the conditional operator (?:).

### Arithmetic Operators

- Operators: +, -, *, /, %, ++, --
- Descriptions:
- Addition: +
- Subtraction: -
- Multiplication: *
- Division: /
- Modulo: %
- Increment: ++
- Decrement: --

### Relational Operators

- Operators: <, >=, ==, !=, >, <=
- Descriptions:
- Less than: <
- Less than or equal to: <=
- Greater than: >
- Greater than or equal to: >=
- Equal to: ==
- Not Equal to: !=

- Relational operators are binary operators that yield a true or false value.

### Logical Operators

- Operators: !, &, |, &&, ||
- Descriptions:
- NOT: !
- AND: &
- OR: |
- Short-circuit AND: &&
- Short-circuit OR: ||

- Logical operators are governed by logical rules, and truth tables are necessary to evaluate logical operations.

### Coding Exercises

- Calculate the area and perimeter of a rectangle with length 15 and breadth 27.
- Check if the two numbers 35 and 75 are equal.

## Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

## Description

Test your knowledge on Java operators which are symbols that perform mathematical or logical functions on operands. Learn about unary operators like bitwise complement, negation, increment, and decrement, binary operators with two operands, and ternary operators with at most three operands.