Skip to main content

Notifications

Community site session details

Community site session details

Session Id :

Objects

Hossein.K Profile Picture Hossein.K 6,648
Objects are created at run-time using the classes defined in the AOT. To create
an object from a class, the class has to be instantiated.
Instantiating a ClassObject instance methods can only be used when an object is instantiated from a
specific class. To instantiate a class, is to create a new instance of it. You can
have multiple instances of a class, meaning, you can have the same code running
multiple times. Think of how in Microsoft
Word, you can have two documents
open at the same time. They are both running the same program, but are two
separate instances of that program.
When you create a new object, call the new() method to execute the code when
the object is instantiated.

Once the class is instantiated, to execute a specific method from your code, use
the reference variable followed by a "dot" operator then the method name.

 myClass myClass;   
myClass = new myClass();
myClass.myMethod();
]The objective of following lab is to instantiate a class, and then execute a method
from that class.


Best Regards,
Hossein Karimi

Comments

*This post is locked for comments