A class contains a Private variable named strState. The variable is associated with a Public property named State. Which of the following is the best way for a parameterized constructor to assign the value stored in its strName parameter to the variable? a. strState = strName b. State = strState c. strState = State.strName d. State = strName
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
A class contains a Private variable named strState. The variable is associated
with a Public property named State. Which of the following is the best way for a
parameterized constructor to assign the value stored in its strName parameter to
the variable?
a. strState = strName
b. State = strState
c. strState = State.strName
d. State = strName
Constructor:
- This is a function which initializes the objects. It also initializes the values to the members after the memory space is allocated to objects.
- Whenever an object is created, constructor is called by the compiler.
- It contains the name of the class.
- A class can contain many constructors.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps