4 write the output of the following Java program and explain
4. write the output of the following Java program and explain the results. (10pts) public class Test private static int sum (int x, int y) int z y; System.out.println (\"x+y z) return (z) public static void main (String args) int x 3, y 4; int i 5; if x y (sum (x, y) 10) system. out.println (\"x y and sum (x, y) 10\") else system. out.println (\"xky or sum (x,y)
Solution
The method sum takes two integer variables as argument and returns their sum.
The main method declares and intializes two integer variables x=3 and y=4 and the passes these two int values are arguments to sum(x,y) as condition in if statement.
First it checks if x is greater than y and then checks if their sum is greater than 10, and if both conditions are true then it will print \"x>y and sum(x,y)>10\" otherwise it prints \"x<y or sum(x,y)<10\".
Since x=3 and y=4 so x is not greater than y thus \"x<y or sum(x,y)<10\" will be printed
