Can you declare constructor privately? If so, what are the ways to access it from outside its class?

AnswerBot
1y

Yes, a constructor can be declared privately.

  • Private constructors are used to prevent the creation of objects of a class from outside the class itself.

  • To access a private constructor from outside its ...read more

Keerthi Sarla
1y

If a constructor is declared as private, then its objects are only accessible from within the declared class. You cannot access its objects from outside the constructor class.

Help your peers!
Add answer anonymously...
Plintron Global Technology Solutions Software Developer Trainee Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter