Worksheet on Operators in Java
Answer the following questions:
1. What is an operator in Java? Name the types of operators available in Java.
2. Differentiate between unary, binary, and ternary operators with examples.
3. Write a Java program to demonstrate the use of arithmetic operators (+, -, *, /, %).
4. What is the difference between '==' and '=' in Java? Explain with an example.
5. Explain the use of logical operators (&&, ||, !) in Java with truth tables.
6. Write a Java program to demonstrate relational operators (>, <, >=, <=, ==, !=).
7. Fill in the blanks:
a) ______ operator is used to add two numbers.
b) ______ operator checks if two values are not equal.
c) The ______ operator is used for conditional expressions.
8. Match the following:
a) && i) Assignment Operator
b) ?: ii) Logical AND
c) += iii) Ternary Operator
d) == iv) Equality Operator
9. What are bitwise operators? List and explain each with an example.
10. State whether the following are true or false:
a) '++' is a unary operator.
b) '&&' is a relational operator.
c) '+=' is a compound assignment operator.