The modulus operator (%) in Java can be used only with variables of integer type.
-
True
-
False
The modulus operator (%) in Java works with both integer types (int, long, short, byte) AND floating-point types (float, double). For example, 5.5 % 2.1 equals 1.3. The statement claims it only works with integers, which is false.
To answer this question, you need to understand the modulus operator (%) in Java and the types of variables it can be used with.
The modulus operator (%) in Java calculates the remainder of one number divided by another. While it is commonly used with integer types, it can also be used with other data types such as floating-point numbers (e.g., double and float).
So, the statement "The modulus operator (%) in Java can be used only with variables of integer type" is incorrect.
Let's go through each option to understand why it is correct or incorrect:
Option A) True - This option is incorrect because the modulus operator (%) in Java can be used with variables of other types, not just integer types.
Option B) False - This option is correct because the statement "The modulus operator (%) in Java can be used only with variables of integer type" is false.
The correct answer is B) False.