4
Reply

How to create object of Class ?

Sandeep Kumar

Sandeep Kumar

8y
544
0
Reply

    Syntax:- class_name variable_name(or)ObjectName = new class_name( ); Example:- Birthday ObjMessage = new Birthday( );Birthday ->Class Name.ObjMessage ->ObjectName. by using this objectname we can access all methods available in that class.If method is public means we can access it throughout the application.if method is private means we can access it within the class file.if method is public means we can access it within the class as well as derived class.

    YourClassName object=new YourClass Name();

    For this you have to know, what is Object actually... An Object within Object Oriented Programming is an instance of a Class. Objects (instances) are created from the Class using the keyword "new". You can create as many instances of a class as you would like. When a new Object is created, then memory will be allocated for the class in heap memory area, which is called as an instance and its starting address will be stored in the object in stack memory area.Now you can create a object of class like this.....ClassName clsname= new ClassName();

    Syntax for creating object of class is : Class Name object=new Class Name();