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

Model 1 Relational Operators Some IDEs (including DrJava) have an \"Interactions

ID: 3742759 • Letter: M

Question

Model 1 Relational Operators Some IDEs (including DrJava) have an "Interactions" feature that allows you to enter a single line of code and see what it does. If you type an expression like 12 and leave off the semi- colon, it will display the resulting value (i.e., 3). In the table below, predict what values will be displayed and identify the relational operator. The first four rows are completed for you Value displayed Relational o int three 3 int four 4 System.out printin(four) three > four boolean isLarger- three > System.out printin sLarger) three four three

Explanation / Answer

<=

1) Four unique boolean expressions used in Model1 are as follows

      i) isLarger = three > four

      ii) three == four

      iii) three < four

      iv) three <= four

2) a) create boolean variable isLarger, assignment operation isLarger = three > four and one comparison operation three > four

    b) boolean isLarger;

        isLarger = three > four

3) after execute all line of code in table the variable three holds value 4 and the variable four also holds value 4. So if we add the expression three != four at the end of the table it results in false there four the example is three != four

4) three == four first present in 7 line, till the 9th line of code the values of three, four are 3, 4 respectively so the expression results false at line 7. But in the line 10 the value of three become 4, and the expression results true in line 11.

5) = is assignment operation, it assigns the right side variable/value to the variable on left side of = operator. == is relational operator it compares or checks if the values of right side is equals to left side of operator ==.

6) the 6 relational operators are used for comparison of left side values with right side values of that operator as follows

   == comparison

    != not equal to

    < less than

    > greater than

    <= less than or equal to

    >= greater than or equal to

Interactions Value displayed Relational operation int three=3 none none int four=4 none none System.out.println(four) 4 none three>4 false > boolean isLarger=three>four none > System.out.println(isLarger) false none three==four false == three<four true < three<=four true

<=

three=four none none three==four true ==
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote