objects in Java in hindi-vishmy1.blogspot.com

Objects in JAVA

Instantiation (initializing) object :- A class provides the blueprint for object basically an object is created from a class. In JAVA the new keyword is used to create object.

तात्कालिकता (प्रारंभिक) वस्तु: - एक वर्ग(class) वस्तु(object) के लिए खाका प्रदान करता है मूल रूप से एक वर्ग से एक वस्तु बनाई जाती है। जावा में new कीवर्ड का उपयोग वस्तु बनाने के लिए किया जाता है।

An object has a state and behavior, the state is stored in the variables, while the methods or function display the behavior of the object.

एक वस्तु का एक राज्य(state) और व्यवहार(behaviour) होता है, राज्य को चर(variables) में संग्रहित किया जाता है, जबकि विधियाँ(methods) या कार्य(function) वस्तु के व्यवहार को प्रदर्शित करते हैं।

There are three steps when creating object from a class

objects in Java in hindi-vishmy1.blogspot.com


1 )- declaration of the object.
2 )- instantiation of the object.
3 )- initialization of the object.

Step-1 :-

Declaration :- A variable declaration with a variable and a data.
When an object is declared, a name associated with that object.

घोषणा: - एक चर(variable) और एक डेटा के साथ एक चर घोषणा(declaration)।
जब कोई वस्तु घोषित की जाती है, तो उस वस्तु से जुड़ा एक नाम।

Step-2 :-

Instantiation :-  The new keyword is used to create an object.
When an object is instantiated, so that memory space can be allocated to that object.

तात्कालिकता: - नए(new) कीवर्ड का उपयोग ऑब्जेक्ट बनाने के लिए किया जाता है।
जब किसी वस्तु को तात्कालिक किया जाता है, ताकि उस स्थान को मेमोरी स्पेस आवंटित किया जा सके।


Step-3 :-

Initialization :- The new keyword is followed by a call to a constructor, this call is initialize the new object.
when an object initialized, initialization is the process of assigning the proper initial value to this allocated space.

प्रारंभिककरण: - नए कीवर्ड के बाद एक निर्माता(constructor) को कॉल किया जाता है, यह कॉल नए ऑब्जेक्ट को इनिशियलाइज़ करता है।
जब किसी ऑब्जेक्ट को इनिशियलाइज़ किया जाता है,  इनिशियलाइज़ेशन इस आवंटित स्थान पर उचित प्रारंभिक मान निर्दिष्ट करने की प्रक्रिया है।

                               Characteristics of  object 

objects in Java in hindi-vishmy1.blogspot.com

1 )- State :- Represents the data of an object, which is stored in variable.

2 )- Behavior :- Represent the behavior of an object, such as show, withdraw, etc.

3 )- Identity :- It is used internally by the JVM, to identify each object uniquely.

Syntax :- 

class_name  object_name = new  class_name();

ex :-

test  t1 = new  test();

Note :- here  test is class name, t1 is object new is keyword used to create object and test(); is constructor.

ex :-

class test 
{
      int a=10;//here a & b is variable and 10 & 20 are values or data.
      int b=20;
      public void show()// here show is a method or fuction
     { 
         int c =a+b;
         System.out.println(c);
     }
     public static void main(String args[])
    {
          test t1 = new  test();
          t1.test();
     }
}

Post a Comment

0 Comments