Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. If num1 = 3 and num2 = 5, what does num1 >= num2 evaluate to? 2. If num1 = 3

ID: 3545140 • Letter: 1

Question

1. If num1 = 3 and num2 = 5, what does num1 >= num2 evaluate to?


2. If num1 = 3 and num2 = 5, what does num1 != num2 evaluate to?


3. If num1 = 3 and num2 = 5, what does !(num1 > num2) && (num1 != num2)
evaluate to?


4. If num1 = 3 and num2 = 5, what does (num1 == num2) || (num2 > num1) evaluate
to?

5. If num1 = 3 and num2 = 5, what does (num1 < num2) && !(num1 != num2)
evaluate to?

6.  If num1 = 3 and num2 = 5, what does (num1 == num2) || (num1 > num2) evaluate
to?

7. What is the syntax of an if-else statement (compare x to 5 as an example. Output
whether x is greater or less than 5)?

8. What operator is used for "is equal to" in the condition of a loop? What if it is 2
Strings instead of 2 primitive data types?




Could you explain how you got these answers

Explanation / Answer

1) If num1 = 3 and num2 = 5,then num1 >= num2 becomes 3>=5 which is false, hence the result will be false


2) If num1 = 3 and num2 = 5, then num1 != num2 becomes 3!=5 which is true, hence the result will be true


3. If num1 = 3 and num2 = 5, then !(num1 > num2) && (num1 != num2) becomes !(3>5) && (3!=5). Since 3>5 is false, so !(3>5) will be true. Also we have in part 2 that (3!=5) is also true. therefore the result will be true && true which will further result into true.


4. If num1 = 3 and num2 = 5, then (num1 == num2) || (num2 > num1) becomes (3 == 5) || (3 > 5). In this case, both (3 == 5) and (3 > 5) are false, hence the result will be false.

5. If num1 = 3 and num2 = 5, then (num1 < num2) && !(num1 != num2) becomes (3 < 5) && !(3 != 5). In this case, (3 < 5) is true. Also (3 != 5) is true according to part 2. So, !(3 != 5) will be false. Hence the AND(&&) of both the expressions will be false.

6. If num1 = 3 and num2 = 5, then (num1 == num2) || (num1 > num2) (3 == 5) || (3 > 5). In this case, both the expressions (3 == 5) and (3 > 5) are false, hence the OR(||) of bothe the expressions will result into false.

7. What is the syntax of an if-else statement (compare x to 5 as an example. Output
whether x is greater or less than 5)?
if(x > 5) System.out.println("x is greater than 5");

else if(x < 5) System.out.println("x is smaller than 5");

8. == works as the "is equal to" operator in the condition of a loop. In case of Strings, == can work but the more preferred operator is the function of String class : String.equals
for example we want to compare two strings str1 and str2, then we can do so by writing str1.equals(str2) or str2.equals(str1)