Back-End/Java_1

[Java] Object and Class

리딩리드 2016. 6. 27. 16:51

  Object and Class


- Object is the physical as well as logical entity

- Class is the logical entity only


1. Object in java

- An entity that has state and behavior is known as an object

- An object has three characteristics

1_1. state: represents data(value) of an object

1_2. behavior : represents the behavior(functionality) of an object such as deposit, withdraw

1_3. identity : Object identity is typically implemented via a unique ID. The value of the ID is not visible to the external user. But is is used internally by the JVM to identify each object uniquely


- Object is an instance of a class

: Class is a template or blueprint from which objects are created


2. Class in Java

- A class is a group of objects that has common properties. It is a template or blueprint from which objects are created

- A class in java can contain

        • data member
        • method
        • constructor
        • block
        • class and interface

2_1. new Keyword

- The new keyword is used to allocate memory at runtime


3. Example

- Object gets the memory in Heap area and reference variable refers to the object allocated in the Heap memory area