Question

In: Computer Science

Given the method static int test(int x, int y, int z){ return(x=y+z); } Which of the...

Given the method
static int test(int x, int y, int z){
return(x=y+z);
}
Which of the follwing is true:
public static void main(String[] args)
{
A System.out.println(test ( 7, 14, 23)) ;
B System.out.println(test ( test ( 7,9, 14) , 23 );
C System.out.println( test ( 14, 23 ) ;
D System.out.println(test(1,2,4), 14, 23)) ;

Solutions

Expert Solution

In case of any queries,please comment. I would be very happy to assist all your queries.Please give a Thumps up if you like the answer.

Option A is true

Correct answer is System.out.println(test ( 7, 14, 23)) ;

Program
public class Main
{
   public static void main(String[] args)
   {
       System.out.println(test ( 7, 14, 23)) ;
   }
  
   static int test(int x, int y, int z)
   {
return(x=y+z);
}
}

Function test will return 23+14 which is equal to 37

Output

37

  1. Option B is false because function test requires 3 arguments. Therefore actual and formal argument lists differ in length. There is also a missing right paranthesis.
  2. Option C is false because function test requires 3 arguments. But test ( 14, 23 ) have 2 arguments. Therefore actual and formal argument lists differ in length. There is also a missing right paranthesis.
  3. Option D is false because there is mismatch in  actual and formal argument.

Related Solutions

static int product(int x,int y){ if(x==0||y==0){//checking if x or y is 0 return 0;//if x or...
static int product(int x,int y){ if(x==0||y==0){//checking if x or y is 0 return 0;//if x or y is 0, then the return value and x*y will be zero. }else if(y<0&&x<0){ x=-x;//Changing the sign of x y=-y;//Changing the sign of y }else if(x>=1){ return (y+product(x-1,y)); } return (x+product(x,y-1)); } find the space complexity and the time complexity of the above algorithm.
Write a static method remove(int v, int[] in) that will return a new array of the...
Write a static method remove(int v, int[] in) that will return a new array of the integers in the given array, but with the value v removed. For example, if v is 3 and in contains 0, 1, 3, 2, 3, 0, 3, and 1, the method will return an array containing 0, 1, 2, 0, and 1. Hint: You can follow two steps to solve this problem: Create an array in the method, let say you called it result....
The temperature at a point (x, y, z) is given by T(x, y, z) = 100e−x2...
The temperature at a point (x, y, z) is given by T(x, y, z) = 100e−x2 − 3y2 − 7z2 where T is measured in °C and x, y, z in meters. (a) Find the rate of change of temperature at the point P(2, −1, 2) in the direction towards the point (4, −4, 4). answer in °C/m (b) In which direction does the temperature increase fastest at P? (c) Find the maximum rate of increase at P.
The temperature at a point (x, y, z) is given by T(x, y, z) = 300e−x2...
The temperature at a point (x, y, z) is given by T(x, y, z) = 300e−x2 − 3y2 − 9z2 where T is measured in °C and x, y, z in meters. (a) Find the rate of change of temperature at the point P(4, −1, 3) in the direction towards the point (6, −2, 6) (b) In which direction does the temperature increase fastest at P? (c) Find the maximum rate of increase at P.
Which of the following are correct for P(x,y,z)= xyz + x(yz)' + x'(y + z) +...
Which of the following are correct for P(x,y,z)= xyz + x(yz)' + x'(y + z) + (xyz)' ? 1) P(0, 0, 1) = 0 2) P(0, 1, 0) = 1 3) P(0, 0, 0) = 1 4) P(1, 1, 1) = 1 5) P(1, 0, 0) = 0
Given function f(x,y,z)=x^(2)+2*y^(2)+z^(2), subject to two constraints x+y+z=6 and x-2*y+z=0. find the extreme value of f(x,y,z)...
Given function f(x,y,z)=x^(2)+2*y^(2)+z^(2), subject to two constraints x+y+z=6 and x-2*y+z=0. find the extreme value of f(x,y,z) and determine whether it is maximum of minimum.
Given a module which implements the function Z= F(X, Y), defined as follows:          X +...
Given a module which implements the function Z= F(X, Y), defined as follows:          X + Y when 10<=X<=20, and 12<=Y<=30 Z =    X - Y when 0<=X<10, and 0<=Y<12                 0 under other conditions           where X and Y are integer parameters for F. 1. Identify the equivalence classes in [X, Y]. 2. List your test cases in [X, Y] based on your equivalence class analysis.
JAVA Given the header of a method public static void m1 (int[ ] max) Write down...
JAVA Given the header of a method public static void m1 (int[ ] max) Write down Java codes to invoke m1 method, declare variables as needed, (Do NOT implement the method)
The curried version of let f (x,y,z) = (x,(y,z)) is let f (x,(y,z)) = (x,(y,z)) Just...
The curried version of let f (x,y,z) = (x,(y,z)) is let f (x,(y,z)) = (x,(y,z)) Just f (because f is already curried) let f x y z = (x,(y,z)) let f x y z = x (y z)
Given x= -2 ,y=-3 , z=5
Given x= -2 ,y=-3 , z=5 Find :- a) 3x-3y b) -2(y-z) c) -(-2+z)-(-3/2 x²)  
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT