Total Page Preview:   000000000554

What is constructor in OOPS in English and Hindi

 

 

 

Constructor in OOPS in English:

In object-oriented programming (OOP), a constructor is a special method that is called when an object of a class is created. Its main purpose is to initialize the object's state or to perform any other necessary setup operations.

 
In C#, a constructor is declared using the class name and the keyword "constructor". Here's an example:
 
 
In the example above, the Person class has a constructor that takes two parameters: name and age. When an object of the Person class is created, the constructor is automatically called and initializes the name and age fields.
 
Here's an example of how to create a Person object and call its DisplayInfo() method:
 
 
In this example, a Person object named john is created using the constructor that takes a name parameter of "John Doe" and an age parameter of 30. The DisplayInfo() method is then called on the john object to display its information.
 
 
Constructor in OOPS in Hindi:
 
Object-Oriented Programming (OOPS) mein, constructor ek special method hota hai jo ek class ka object create karne par call hota hai. Constructor ka main purpose object ki state ko initialize karna ya koi aur zaroori setup operations perform karna hota hai.
 
C# mein, constructor class ke naam aur "constructor" keyword ka use karke declare kiya jata hai. Neeche ek example diya gaya hai:
 
 
Upar ke example mein, Person class ek constructor ka use kar rahi hai jo do parameters leta hai: name aur age. Jab Person class ka object create kiya jata hai, constructor khud ba khud call ho jata hai aur name aur age fields initialize kar deta hai.
 
Neeche ek example diya gaya hai jisme ek Person object create kiya jata hai aur uske DisplayInfo() method ko call kiya jata hai:
 
 
Is example mein, Person class ka ek john object create kiya gaya hai jo "John Doe" name parameter aur 30 age parameter ke sath ek constructor ka use karke banaya gaya hai. john object par DisplayInfo() method call kiya jata hai jisse uski information display hoti hai.
 
 
 
 
 
 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: