Operators in Java Flashcards
What is an expression built using?
Constants, variables, operators and method calls
What are operators?
Symbols which are used in expressions to perform arithmetic or logical operations
What is operand?
The variable or literal on which the operator is applied
Name the three forms of operators
- Unary
- Binary
- Ternary
What is a unary operator?
An operator that has just one operand.
Give examples of unary operators
+,-, ++, –, !
What is a binary operator?
An operator that has two operands in known as binary operator
Give examples of binary operators
+, %, >, &&, etc
What is a ternary operator?
An operator that has three operands is known as a ternary operator
Give example of a ternary operator
?:
What are arithmetic operators?
+, -, *, /, %
What is the result when two integers are divided?
The result of the division will also be an integer (the decimal part will be truncated
What are the two forms of the plus and minus operators?
- Unary form - adding/subtracting stuff
2. Preceding an operand
Name the process of joining two strings together
Concatenation
What are relational operators?
They determine the relationship between the two operands by comparing them
What is the outcome of relational operators?
The outcome of these operations is a boolean value which is either true or false
How many relational operators does Java provide?
6 types
Name the six types of relational operators
- Greater than (>)
- Less than (=)
- Less than or equal to (<=)
- Not equal to (!=)
What are logical operators?
They operate only on boolean operands and are used to construct simple decision making expressions
Name some logical operators
- Logical AND - &&
- Logical OR - I I
- Logical NOT - !
What is the logical && operator?
It is a binary operator and is used to combine two conditions or expressions. The resultant value is a boolean value. The result is true if both values are two, and false if either is false