8. 110 Points] Objects and Memory Look at the following code segment. You can as
ID: 3881517 • Letter: 8
Question
8. 110 Points] Objects and Memory Look at the following code segment. You can assume that named Weather java and the ProbTvo class is stored in a file named ProbTwo java public class Weather the Weather class is stored in a file private double humidity: public Weather (double theHumidity)t humidity = theHumidity; public void setHumidity (double theHumidity) humidity -theHumidity public double getHumidityO return humidity: public class ProbTwo ( public void one(int x, int y) t System.out.printin(xy) System.out.println (x % y); System.out.printin(x / y) i system.out.printin (x(y/5)) system.out.printin(x -y)i public void two (double f, double g, double k) if ( (f k) II false) System.out.printin ("Case 1") else f System.out.println ("Case 2") else f system.out.println ("Case 3"Explanation / Answer
a) probe2.one(8, 4)
8 and 4 is passed to the function
1) x*y = 32
2) x%y = 8%4 = 0
3) x/y = 8/5 = 1
4) x + y /5 = 8 + 4/5 = 8
5 x==y : 8==4 = 0
b) two ( 5, 10, 7 )
=> 10 > 5
=> 10 > 7 but its ! so its false
=> Case 2 [Answer]
two ( 5, 8, 9 )
=> 8 > 5
=> 8 > 9 is false but its ! so its true
=> Case 1
c) three(3)
=> Output : 1 3
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.