Q 1What do we call an operator that operates on only one operand?
A - An operator that operates on only one operand is called a unary operator.
A - An operator that operates on only one operand is called a unary operator.
A - An operator that operates on two operands is called a binary operator.
A - Both. As a binary operator, the minus sign causes its right operand to be subtracted from its left operand. As a unary operator, the minus sign causes the algebraic sign of the right operand to be changed.
A - For those languages that support it (such as C++) operator overloading means that the programmer can redefine the behavior of an operator with respect to objects of a new type defined by that program.
A 5- False: Unfortunately, Java does not support operator overloading.
A - The above listed operators in order are: = != + (type)
A - The plus sign (+) is automatically overloaded in Java. The plus sign can be used to perform arithmetic addition. It can also be used to concatenate strings. However, the plus sign does more than concatenate strings. It also performs a conversion to String type. When the plus sign is used to concatenate strings, the operand on the right is automatically converted to a character string before being concatenated with the operand on the left. This assumes that the compiler knows enough about the operand on the right to be able to successfully perform the conversion. It has that knowledge for all of the primitive types and most or all of the built-in reference types.
A - The cast operator is used to purposely convert from one type to another.
A - False: The increment operator is a unary operator.
No comments:
Post a Comment