Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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