What output do we get? How do we get that output?
Consider the following method :
public static void processArray (int [] array) {
int x = 0;
for (int i = 0; i < array.length - 1; i++ ) {
if (array [i] < array [i+1]) {
System.out.println (i + 1) ;
}
}
}
In the left-hand column below are specific arrays of integers. Indicate in the right- hand column what value would be printed by method processArray if the integer array in the left-hand column is passed as its parameter (Note: the output can be empty , buy you need to specify it explicitly). Original Contents of Array Output into
int [] a1= {34} ;
processArray (a1) ;
int [] a2 = {7, 1} ;
processArray (a2) ;
int [] a3 = {14, 68};
processArray (a3) ;
int [] a4 = {1,2,3,4};
processArray (a4) ;
int [] a5 = {-34};
processArray (a5);
int [] a1= {34} -> it will not print anything as it has only 1
element
int [] a2 = {7, 1} ->it will not print as 7 <1 is false
int [] a3 = {14, 68} -> it will print 1 as 14<68
int [] a4 = {1,2,3,4} -> it will print 1 2 3 as
1<2<3<4
int [] a5 = {-34} -> it will not print anything as it has only 1
element
Note : Please comment below if you have concerns. I am here to help
youIf you like my answer please rate and help me it is very Imp for
me
Get Answers For Free
Most questions answered within 1 hours.