The following Java program has 11 errors. Can you find them all? 1 2 3 4 5 6 7 8
ID: 3662862 • Letter: T
Question
The following Java program has 11 errors. Can you find them all?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
public class StringOops { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("Type your name: "); String name = console.nextString(); process(name); } public static void process(string "name") { if (name == Whitaker) { System.out.println("You must be really awesome."); } replace("a", "e"); toUppercase(name); name.substring(0, 3); System.out.println(name + " has " + name.length + " letters"); } }
Explanation / Answer
There are 8 errors
1. Scanner cannot be resolved to a type
2. The method nextString() is undefined for Scanner
3. The method process() in the type StringOops is not applicable for the arguments (String
4. Syntax error on token ""name"", invalid VariableDeclaratorId
5. insert } to complete class body
6. Syntax error on token ""name"", invalid VariableDeclaratorId
7. The method process() in the type StringOops is not applicable for the arguments (String)
8. Syntax error on token "}", delete this token
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.