Which line will cause a compilation error?
public class Sample81
{
static final int MAX = 10;
public static void main(String[] args)
{
assert MAX = 20;
System.out.println(MAX);
}
}
Answer: A
Two faults meet on one line and the compiler reports both: a final field cannot be assigned, and the assignment yields an int where a boolean is required. Either alone would be fatal. The author almost certainly meant ==.
Please log in or register to report this question.