HCL Interview Question for Developer Program Engineers


Country: India
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
0
of 0 vote

Singleton class is used to make sure that there is only one instance of singleton class in JVM.For e.g. Logger class will be getting used by almost all the classes in the application. There is no point of creating a separate instance for logger class by different classes.

- Crystal January 11, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I gave the same answer. But I was asked- if there are multiple instances, you can use syncronisation techniques like mutex. Why do you need a single instance?

- Sandeep January 11, 2016 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I gave the same answer. But I was asked- if you have multiple objects, you can syncronise acces using mutex. Why do you need single object?

- Sandeep January 11, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Using synchronization it is possible to have synchronization among different instances but where as singleton is to keep a single instance of any object through out of your application life cycle.

- Jeevan January 12, 2016 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Single object centralizes its members (such as parameters), reducing memory and other overhead. It also allows you to write cleaner code without the inherent complexities of mutex operations.

- merkidemis January 14, 2016 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More