What is the output of this code segment - in one short


1. What is the output of this code segment?
1 double [] a = {-1.2, 3.1, -4.7, 38.0, 0.01;
2 double temp = a[0];
3
4 for (int i = 1; i < a.length; i++) {
5 if (a[i] < temp) {
6 temp = a[i];
7
8 }
9
10 System.out.println (temp);

2. What does this method do? In one short English sentence describe the task accomplished by this method.
1 public static int foo(int [] a) {
2 int temp = 0;
3 for (int i = 0; i < a.length;
4 if (a[i] < 0) {
5 temp++;
6 }
7 }
8 return temp;
9

3. What does this method do? In one short English sentence describe the task accomplished by this method.
1 public static char [] bar(String [] a) {
2 char [] tmp = new char[a.length];
3
4 for (int i = 0; i < a.length; i++) {
5 if (a[i].length() > 0) {
6 tmp[i] = a[i].charAt(0);
7
8 else {
9 tmp[i] = ";
10
11
12 return tmp;
13 }

Solution Preview :

Prepared by a verified Expert
JAVA Programming: What is the output of this code segment - in one short
Reference No:- TGS02384662

Now Priced at $10 (50% Discount)

Recommended (90%)

Rated (4.3/5)