Class:
Conceptually, a class represents a concept, a template for creating instances (objects). In the computer, a class is a chunk of memory, set aside once, when the class is loaded at run-time. A class has the following parts:
The name of the class.
Room for all the static members of the class.
A class can be drawn as a box. The header class SPoint gives the class name, and the box itself
contains the static members of the class:
Object:
Conceptually, an object is an instance of a concept (a class). In the computer, an object is a chunk of memory, set aside by an object creation expression new C(...); . Every evaluation of
an object creation expression new C(...) creates a distinct object, with its own chunk of computer
memory. An object has the following parts:
Conceptually, a class represents a concept, a template for creating instances (objects). In the computer, a class is a chunk of memory, set aside once, when the class is loaded at run-time. A class has the following parts:
The name of the class.
Room for all the static members of the class.
A class can be drawn as a box. The header class SPoint gives the class name, and the box itself
contains the static members of the class:
Object:
Conceptually, an object is an instance of a concept (a class). In the computer, an object is a chunk of memory, set aside by an object creation expression new C(...); . Every evaluation of
an object creation expression new C(...) creates a distinct object, with its own chunk of computer
memory. An object has the following parts:
- A reference to the class C of the object; this is the class C used when creating the object.
- Room for all the non static members of the object.
An object can be drawn as a box. The header : SPoint gives the object's class (underlined), and the remainder of the box contains the nonstatic members of the object.
Inner Objects:
When NIC is an inner class (a nonstatic member class, or a local class in nonstatic code) in a class C,then an object of class NIC is an inner object. In addition to the object's class and the nonstatic fields,an inner object will always contain a reference to an enclosing object, which is an object of the ,innermost enclosing class C. The enclosing object reference can be written C.this in Java programs.
An object of a static nested class, on the other hand, contains no reference to an enclosing object.
RELATED POST
DECLARATION OF CONSTRUCTOR IN JAVA
Inner Objects:
When NIC is an inner class (a nonstatic member class, or a local class in nonstatic code) in a class C,then an object of class NIC is an inner object. In addition to the object's class and the nonstatic fields,an inner object will always contain a reference to an enclosing object, which is an object of the ,innermost enclosing class C. The enclosing object reference can be written C.this in Java programs.
An object of a static nested class, on the other hand, contains no reference to an enclosing object.
RELATED POST
DECLARATION OF CONSTRUCTOR IN JAVA
No comments:
Post a Comment