Q1. Distinguish between a unary, a binary and a ternary operator. Give examples of Java operators for each one of them.
Ans. A unary operator requires a single operand. Unary +, unary -, ++, — etc. are some unary operators in Java.
A binary operator requires two operands.
+ (add), – ( subtract), *, /, % etc. are some binary operators in Java.
A ternary operator requires three operands. ? : (the conditional operator) is a ternary operator in Java.