There are 3 syntax and/or logic errors in the code below. identify them and sugg
ID: 3926105 • Letter: T
Question
There are 3 syntax and/or logic errors in the code below. identify them and suggest how they might be corrected. Line numbers are there for your reference.//check to see if three hard-coded strings are in//alphabetical (lexicographical) order public class questions public static main (String {} args) String s1 = "apples"; String s2 = "coconuts"; String s3 = "bananas"; if(s1.equals(s2) && s2.equals(s3)) System.out.printin("Strings are equal!"); System.out.println("Your strings are in order (ascending) !");} else (s1.compareTo(s2) >= 0 && s2.comopareTo(s3)Explanation / Answer
1)There is no semicolon at the end of line 19.
2)In line 4, void is missing. Change it to public static void main(String[] args) {
3) In line 15, change else to else if.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.