Multiple choice technology web technology

abstract class A {} // 1 transient class B {} // 2 private class C {} // 3 static class D {} // 4 Which of these declarations will not produce a compile-time error?

  1. 1

  2. 2

  3. 3

  4. 4

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

In Java, top-level classes can only be public or abstract (and abstract is implicitly public). The transient modifier applies only to fields, not classes. Private and static modifiers can only be used on nested classes, not top-level classes. Therefore, only declaration 1 is valid.