Can we have a private constructor ?

Answer Posted / srikanth

We can make a constructor Private or protected.
1. Private constructor is classic example of implementing a
singleton class( A class with a single instance)
2. Protected constructors can be used when the class cannot
be instantiated but can only be inherited.

Is This Answer Correct ?    108 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

write a code for this. serial_number contained in the header of the file will be read , if this serial number is less than a previous serial number within a successfully processed file, or is the same as another serial number within a successfully processed file, or if the field contains anything other than 7 digits, then the file must error with the reason ‘Invalid SERIAL_NUMBER’.

1778


What are objects in oop?

608


class type to basic type conversion

1835


Advantage and disadvantage of routing in telecom sector

786


Why it is called runtime polymorphism?

573






What is difference between data abstraction and encapsulation?

615


Explain virtual inheritance?

682


What is solid in oops?

600


if i have same function with same number of argument but defined in different files. Now i am adding these two files in a third file and calling this function . which will get called and wht decide the precedence?

2753


What are different oops concepts?

574


What is class and example?

567


What is a class and object?

598


What is object in oops?

612


What is this pointer in oop?

555


What does <> mean pseudocode?

622