Home | Java - The General Form of a Class

Chapter: Web or internet Programming : JAVA

Java - The General Form of a Class

A class is declared by use of the class keyword. The classes that have been used up to this point are actually very limited examples of its complete form. Classes can (and usually do) get much more complex.

 

The General Form of a Class

 

A class is declared by use of the class keyword. The classes that have been used up to this point are actually very limited examples of its complete form. Classes can (and usually do) get much more complex. A simplified general form of a class definition is shown here:

 

class classname {

 

type instance-variable1; type instance-variable2; // ...

 

type instance-variableN;

 

 

type methodname1(parameter-list) {

 

// body of method }

 

 

type methodname2(parameter-list) {

 

// body of method }

 

// ...

 

type methodnameN(parameter-list) { // body of method } }

 

 

The data, or variables, defined within a class are called instance variables. The code is contained within methods. Collectively, the methods and variables defined within a class are called members of the class. In most classes, the instance variables are acted upon and accessed by the methods defined for that class. Thus, as a general rule, it is the methods that determine how a class’ data can be used.

 

 

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Web or internet Programming : JAVA : Java - The General Form of a Class |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.