Question

What is the state of the program if the below function is called with parameters mySpecialArray(1,...

What is the state of the program if the below function is called with parameters mySpecialArray(1, 2)

public int[] mySpecialArray(int a, int b) {
    int[] prep = new int[2];
    prep[0]=a;
    prep[1]=b;
    return prep;
}
0 0
Add a comment Improve this question Transcribed image text
Answer #1

mySpecialArray(1, 2) will return the array [1,2]

an array of two integers prep will be created.

prep[0]=a=1

prep[1]=b=2

this prep will be returned.

Add a comment
Know the answer?
Add Answer to:
What is the state of the program if the below function is called with parameters mySpecialArray(1,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please write program in C++ Write a function called randCount with no parameters. The function should...

    Please write program in C++ Write a function called randCount with no parameters. The function should randomly generate 5 numbers between 8 to 15 and counts how many times a multiple of 2 occurred. Return the answer to the calling function. please write the program in C++

  • The function used in the following program is supposed to take 2 parameters (arguments) and switch...

    The function used in the following program is supposed to take 2 parameters (arguments) and switch the contents of the 2 and send them back to the calling program, but the values are not swapped and both have the same number in them. Select the option that fixes the problem? void interchange(int &arg1, int &arg2) { arg2 = arg1; arg1 = arg2 ; } int main() { int num1 = 4 , num2 = 5; interchange(num1, num2); cout << "Number...

  • In C++: A. Write 3 functions that are called in the program. 1. Function readInput prompt...

    In C++: A. Write 3 functions that are called in the program. 1. Function readInput prompt user to enter an integer to store to the parameter. 2. Function isPerfectSquare take an integer parameter and checks whether it's a perfect square, that it's square root is an integer. 3. Function min3 return the mainimum value of the parameter values, it shouldn’t use any if statement to compare the parameters but call min2 to do the comparison. Extra Credit: Function printPrimeFactorization print...

  • Define an ordinary function called DisplayMin that has three parameters: the first two parameters are parallel...

    Define an ordinary function called DisplayMin that has three parameters: the first two parameters are parallel arrays of different types and the third argument is of type size_t representing the size of both arrays. The function DisplayMin must work when called with various types of actual arguments, for example string DisplayMin(string names[], int calories[], int size) or int DisplayMin(int calories[], float prices[], int size). (Parallel Arrays are two arrays whose data is related by a common index. For example: with...

  • Write a function template named summarray, with two parameters: and array called are and an int...

    Write a function template named summarray, with two parameters: and array called are and an int holding the number of elements in arr. The function should return the sum of the elements in arr. this template must work for double or int arrays. Show a sample function call to the template function you wrote. What would you have to do to use the templates sumArray function with an array of objects of a custom class?   

  • I need help making my array into a function that can called by the main function...

    I need help making my array into a function that can called by the main function using my program. This is C programming int prime (int x) { int i; i = 2; while (i < x) { if (x % i == 0) return 0; i++; } return 1; } int main (void){ int n; scanf ("%d", &n); if (n < 1) { printf ("Error: at least one data value must be provided.\n"); return 1; } int a[n]; int...

  • Write a C++ program that contains a function called swapNums. This function takes two integer parameters,...

    Write a C++ program that contains a function called swapNums. This function takes two integer parameters, swaps them in memory, and outputs the results (there is nothing to return). In main, ask the user to enter two different numbers, output them as entered (step 1), call the function swapNums() which will output the numbers swapped (step 2), and then output the values again in main (step 3). You should have three sets of output. Sample run (10 and 5 were...

  • Code written in NASM Function called findLargest Write a function called findLargest that receives two parameters:...

    Code written in NASM Function called findLargest Write a function called findLargest that receives two parameters: an unsigned doubleword array and the length of the array. The function must return the value of the largest array member in eax. Preserve all registers (except eax) that are modified by the function. Write a test program in main that calls findLargest three times, each call using a different array with different lengths. Function called countHits Write a function called named countHits that...

  • Make a public class called ManyExamples and in the class... Write a function named isEven which...

    Make a public class called ManyExamples and in the class... Write a function named isEven which takes in a single int parameter and returns a boolean. This function should return true if the given int parameter is an even number and false if the parameter is odd. Write a function named close10 which takes two int parameters and returns an int. This function should return whichever parameter value is nearest to the value 10. It should return 0 in the...

  • Trying to solve the following problem based on the below program. It's from Chapter 2 in...

    Trying to solve the following problem based on the below program. It's from Chapter 2 in Computer Systems (Fourth Edition) by J. Stanley Warford Section 2.4 . The function sum in Figure 2.25 is called for the first time by the main program. From the second time on it is called by itself. "(a) How many times is it called altogether? (b) Draw a picture of the main program variables and the run-time stack just after the function is called...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT