Classes


A class provides the blueprint for an object. A class is a named block of code that defines the state (fields) and behavior (methods) for objects that are instances of the class. The fields and methods are called the members of the class. The fields can be either primitive ( int , double , etc) or reference (objects, arrays) types. The class members can be instance, meaning they are associated with an instance of the class, or static, meaning there is one copy shared by all instances of the class. Members can be given access modifiers that determine how and if the member can be accessed outside of the class in which it is declared. While a class declares the data structure for an object, each object is free to assign its own values to that data structure. Every object will have its own copies of the nonstatic fields of its class.

Every Java program will have at least one class. All executable statements in a Java program must be placed inside a class. An abstract class is one that provides the blueprint for other classes. A subclass is one that extends the capabilities of another class. A class can be declared to be final , in which case it cannot be extended.



Technical Java. Applications for Science and Engineering
Technical Java: Applications for Science and Engineering
ISBN: 0131018159
EAN: 2147483647
Year: 2003
Pages: 281
Authors: Grant Palmer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net