173k views
4 votes
Errors can be syntax errors or logic errors (the code works, but not as intended).

Which of the following statements contains an error?
I.import java.util.Scanner;
II.public static void Main(String [] args)
III.Scanner in = new Scanner(System.out);
a.I only
b.II only
c.III only
d.I and II only
e.II and III only

User Eltariel
by
7.0k points

1 Answer

0 votes

Final answer:

The question contains two errors: a syntax error in statement II due to incorrect capitalization of 'main', and a logical error in statement III because Scanner should use System.in, not System.out.

Step-by-step explanation:

The question asks us to identify which of the given statements contains an error. Statement I, import java.util.Scanner;, is correct as it correctly imports the Scanner class. Statement II, public static void Main(String [] args), has a syntax error because the 'Main' method in Java should be spelled with a lowercase 'm', as in 'main'. Statement III, Scanner in = new Scanner(System.out);, contains a logical error because the Scanner class is used to read input from the input stream, typically System.in, not System.out. Hence, the correct answer is e. II and III only.

User Fjalcaraz
by
8.1k points