Computer Science, asked by annyannlyn, 8 months ago

What is the value returened by f() defined below?
public static int f (int x, int y){return (x>y)?y:x;}

Answers

Answered by monurajkonwar456
0

Answer:

add_int(int x,int y) - This part of code should be clear that 'add_int' is the name of method and it is taking two parameters of type int.

int add_int(int x,int y) - 'int' before the method name means that this method will return an integer. i.e. we will get some integer value whenever we will call this method.

return x+y; - This part returns an integer having the value 'x+y' since our method has to return an integer.

Now come to the main method

int z = add_int(x+y); - We are calling 'add_int' method by passing two integers 2 and 4. And this will return 'x+y' i.e. '2+4'. So, this statement is equivalent to:

int z = 2+4; or int z = 6; (6) returned by 'add_int(2,4)'.

Now let's see an example:

class Area{

public static double getArea(double x,double y){

return x*y;

}

public static void main(String[] args){

double z = getArea(10.2,23.4);

System.out.println(z);

}

}

Similar questions