Tip:A–D to answerE for explanationV for videoS to reveal answer
Which of the following is a valid class declaration?
- A.
class A {int x;}
- B.
class B { };
(Correct Answer) - C.
public class A { }
- D.
object A {int x;);
Correct Answer: class B { };
Explanation
The Syntax Equation
The basic structure of a class declaration can be represented by the following logical sequence:
Declaration=Access Modifier+class+ClassName+{Body}
Explanation
The Syntax Equation
The basic structure of a class declaration can be represented by the following logical sequence:
Declaration=Access Modifier+class+ClassName+{Body}