Computer Science, asked by hgulzah7005, 1 year ago

Explain class declaration with syntax and example

Answers

Answered by nisha618
1
At minimum, a class declaration must contain the class keyword and the name of the class that you are defining. Thus the simplest class declaration that you can write looks like this:

class NameOfClass { . . . }

For example, this code declares a new class named ImaginaryNumber:

class ImaginaryNumber { . . . }

Class names must be a legal Java identifier and, by convention, begin with a capital letter. Often, a minimal class declaration such as this one is all you'll need. However, the class declaration can say more about the class. More specifically, within the class declaration you can:Declare what the class's superclass is.List the interfaces implemented by the class.Declare whether the class is public, abstract, or final.
Similar questions