Accenture Java Programming Practice Question
Choose the correct order of the Java code fragments: 1) public class Main, 2) import java.util.Scanner;, 3) {, 4) // Some code here, 5) }, 6) package test;Answer options
A
6, 2, 1, 3, 4, 5
B
1, 2, 3, 4, 5, 6
C
2, 6, 1, 3, 4, 5
D
1, 3, 2, 4, 5, 6
Correct answer: 6, 2, 1, 3, 4, 5
Explanation
In Java, the package declaration comes first, followed by imports, then the class declaration and class body.