Given:
1. public class Mud {
2. //insert code here
3. System.out.println(“hi”);
4. }
5. }
And the following five fragments:
public static void main(String…a) {
public static void main(String.* a) {
public static void main(String… a) {
public static void main(String[]… a) {
public static void main(String…[] a) {
How many of the code fragments, inserted independently at line 2, compile?
A.
0
B.
1
C.
2
D.
3
E.
4
F.
5
Explanation:
* public static void main(String…a) {
compiled successfully* public static void main(String.* a) {
Main.java:2: <identifier> expected
public static void main(String.* a) {
^
Main.java:2: ‘)’ expected
public static void main(String.* a) {
^
Main.java:2: ‘;’ expected
public static void main(String.* a) {
^
3 errors* public static void main(String… a) {
compiled successfully* public static void main(String[]… a) {
compiled successfully* public static void main(String…[] a) {
Main.java:2: <identifier> expected
public static void main(String…[] a) {
^
Main.java:2: ‘;’ expected
public static void main(String…[] a) {
^
Main.java:2: <identifier> expected
public static void main(String…[] a) {
^
3 errors