157k views
4 votes
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.in);
a) I only
b) II only
c) III only
d) I and II only
e) II and III only

User Barq
by
7.3k points

1 Answer

3 votes

Final answer:

The statement with an error is II) public static void Main(String [] args) as the main method should be written in all lowercase as main. Statements I) and III) are correct and contain no syntax errors.

Step-by-step explanation:

The statement that contains an error among the ones provided is II) public static void Main(String [] args). In Java, the method signature for the main method should be public static void main(String[] args), with 'main' written in all lowercase.

There is no error in statement I) import java.util.Scanner; because it is the correct syntax for importing the Scanner class from the java.util package.

Statement III) Scanner in = new Scanner(System.in); is also correct and is the typical way of creating a new Scanner object to read input from standard input (System.in).

User Trungduc
by
7.9k points