Students are not allowed to use IDEs such as NetBeans, IntelliJ IDEA, or similar software to do the test.
Question 1 (3 points): Review the following class and find (at least) 6 issues in the code (i.e.,coding practice, compile errors, potential logical issues, etc.) (Use question 1 template)
public import java.util.Scanner;
class LongestString Finder {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String[] strings = null;
String LONGEST_STRING = null;
int stringCount;
System.out.print("Enter the number of strings: ");
stringCount = scanner.nextInt();
scanner.nextLine();
strings = new String[stringCount];
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
}
20
21
10
22
23
24
}
25
}
26
27
System.out.println("The longest string is: " + LONGEST_STRING);
28
}
}
29
for
(int i = 0; i < stringCount; i++) {
System.out.print("Enter string #" + (i+1) + ": ");
strings[i] = scanner.nextLine();
for (int i = 0; i <= stringCount; i++) {
if (strings[i].length() > LONGEST_STRING.length()) {
LONGEST_STRING = strings[i];
Zoom
+ 100%
Close