Why will the code not compile?

Given:
public class Basic {
private static int letter;
public static int getLetter();
public static void Main(String[] args) {
System.out.println(getLetter());
}
}
Why will the code not compile?

Given:
public class Basic {
private static int letter;
public static int getLetter();
public static void Main(String[] args) {
System.out.println(getLetter());
}
}
Why will the code not compile?

A.
A static field cannot be private.

B.
The getLetter method has no body.

C.
There is no setletter method.

D.
The letter field is uninitialized.

E.
It contains a method named Main instead of ma

Explanation:
The getLetter() method needs a body public static int getLetter() { }; .



Leave a Reply 0

Your email address will not be published. Required fields are marked *