Multiple choice technology programming languages

What gets displayed on the screen when the following program is compiled and run. Select the one correct answer. protected class example { public static void main(String args[]) { String test = "abc"; test = test + test; System.out.println(test); } }

  1. The class does not compile because the top level class cannot be protected.

  2. The program prints "abc"

  3. The program prints "abcabc"

  4. The program does not compile because statement "test = test + test" is illegal.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In Java, a top-level class cannot have protected access. Only public or default (package-private) access are allowed for top-level classes. The protected modifier is only valid for class members (methods, fields, nested classes).