Help with Java Programming? Consider the following declrations. int y = 5; int z = 10; Which of the following expressions evaluates to true? A. y > 5 && z >= 10 B. z / y >= 2 && y * 2 > z C. y - z > 0 || y * 4 == z * 2 D. y + z == z + y && z - y == y - z
The or statement.
You must consider this rules: For OR ( In java is || ): (true condition) or (false condition) = true declaration , in java (or) is equals to || (false condition) or (true condition) = true declaration (false condition) or (false condition) = false declaration (In OR, It Just needs one true condition for the declaration has be true) For AND (In java is && ): (true condition ) AND (false condition) = false declaration (true condition) AND (false condition) = false declaration (false condition) AND (false condition) = false declaration (true conditoin) AND (true condition) = true declaration (In AND, It needs both true conditions for the declaration has be true) ATT: the sol. is C.
In C, the second condition : y * 4 == z * 2 is true , therefore, the declaration is true. (Remember the OR rules).
Join our real-time social learning platform and learn together with your friends!