Question: 1.What is the output of this code segment? double [] a = {-1.2, 3.1, -4.7, 38.0, 0.0}; double temp = a[0]; for (int i =

1.What is the output of this code segment?

 double [] a = {-1.2, 3.1, -4.7, 38.0, 0.0}; double temp = a[0]; for (int i = 1; i < a.length; i++) { if (a[i] < temp) { temp = a[i]; } } System.out.println (temp); 

2.What does this method do? In one short English sentence describe the task accomplished by this method.

 public static int foo(int [] a) { int temp = 0; for (int i = 0; i < a.length; i++) { if (a[i] < 0) { temp++; } } return temp; } 

3.What does this method do? In one short English sentence describe the task accomplished by this method.

 public static char [] bar(String [] a) { char [] tmp = new char[a.length]; for (int i = 0; i < a.length; i++) { if (a[i].length() > 0) { tmp[i] = a[i].charAt(0); } else { tmp[i] = ' '; } } return tmp; } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!