Question: int x = 4; if (x < 0) { x *= -1; } What does the code snippet do? a. the code snippet creates the
int x = 4;
if (x < 0) {
x *= -1;
}
What does the code snippet do?
| a. | the code snippet creates the absolute value of x |
| b. the code snippet cannot work since x is greater than 0. |
| c. Converts x to a negative value. |
| d. None of the above |
2.) Given the following function prototype:
public static void Display(int[] ary)
Select the correct choice below.
| a. Display returns an integer value. |
| b. | The array is passed by value to the function. |
| c. | The argument passed to the function is an integer array. |
| d. | None of the above. |
3.) Large complex problems are best solved by __________ .
| a.) | dividing the problem into functions |
| b.) | implementing the code sequentially in function main() |
| c.) | using a debugger to step through the code |
| d.) | None of the above |
4.)
Select the choice that initializes all elements in the array to -1.
| a.) int[][] ary = new int[N][N]; for (int i = 0; i < N; i++) { ary[i][j] = -1; }
|
| b.) int[][] ary = new int[N][N]; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { ary[i][j] = -1; }}
|
| c.) int[][] ary = new int[N][N]; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { ary[i] = -1; }} |
| d.) None of the above |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
