Question
1)Given the following method Given int[] num = {111, 77, 222}, what are the correct statements to complete the following method (int min) that returns
1)Given the following method Given int[] num = {111, 77, 222}, what are the correct statements to complete the following method (int min) that returns the smallest value in the array?
public static int min(int[] arr) {
int smallest = arr[0];
for (int i = 1; i < arr.length; i++) {
____________________________________
____________________________________
}
}
return smallest;
}
Select one:
A.if (arr[1] < smallest)
smallest = arr[1];
B.if (arr[i] > smallest)
smallest = arr[i]
C.if (arr[i] < smallest)
smallest = arr[i]
D.if (arr[0] < smallest)
smallest = arr[0];
2)(void printingSize), what will be the output of this program fragment?
static void printingSize(){
int[] value1 = {31, 22, 25};
int[] value2 = {3, 2};
value1 = value2;
System.out.print(value1.length);
System.out.print(value1[1]);
System.out.println(value2[1]);
}
Select one:
A.322
B.3222
C.222
D.2222
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started