19 solutions available
Question 1What is a constructor? Why do you need a constructor?
Question 2If the constructor is automatically generated by the compiler, why do you need to define your own constructor?
Question 3Explain the statement, "you cannot invoke constructors as normal method calls".
Question 4Describe the importance of parameterised constructors.
Question 5Write a class specifier (along with its constructor) that creates a class student having two private data members : rollno and grade and...
Question 6Explain the concept of constructor overloading with an example.
Question 7What is the use of the keyword this?
Question 8Define a constructor function for a Date class that initializes the Date objects with given initial values. In case initial values are not...
Question 9What condition(s) a function must specify in order to create objects of a class ?
Question 10Constructor functions obey the usual access rules. What does this statement mean ?
Question 11How are parameterized constructors different from non-parameterized constructors?
Question 12What are benefits/drawbacks of temporary instances ?
Question 13How do we invoke a constructor ?
Question 14How can objects be initialized with desired values at the time of object creation ?
Question 15When a compiler can automatically generate a constructor if it is not defined then why is it considered that writing constructors for a...
Question 16'Accessibility of a constructor greatly affects the scope and visibility of their class.' Elaborate this statement.
Question 17List some of the special properties of the constructor functions.
Question 18What is a parameterized constructor ? How is it useful ?
Question 19Design a class to represent a bank account. Include the following members:Data membersName of the depositorAccount numberType of...