Bloomberg LP Interview Question for Software Engineer / Developers






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

In Java, Create a static function that sets the object's reference to null.

- Karthik December 07, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

sounds acceptabel

- chandan.here4u May 21, 2011 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

provide another static function which calls getInstance and delete on return value

- Anonymous April 26, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

May work. I think the behavior will be undefined after "delete this" but I'm not sure about this.
P.S. "Undefined" means "it will probably work but without any guarantee".

- Anonymous June 02, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Have a reference count decremented each time the object is released and delete the obj when it reaches 0

- Anonymous April 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

huh? a singleton is provides one and only one object for the entire lifetime of the application. So why do you need a reference count? If it deletes, it deletes that same pointer.

Or are you talking about how many times it has been accessed/used in the program so that if it was deleted, it will not cause a crash because other section of the source code base is still using/referencing it?

- Anonymous May 23, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

i believe he is talking about instance pool and not singlton. For singleton, we can simply have a remove method which will set the static reference variable holding the single object to null. Correct me if I am wrong.

- tetura May 31, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

static method will not have this pointer..so it is not a suicide ...

- Karthik Raj June 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

to avoid accidental delete move destructor to private

make a static object so that compiler automatically deletes in the end of the programm.....but then it might have issues like dead reference problem.....

Singleton& Singleton::GetInstance()
{

static Singleton single;
return single;
}

- avanilkumar September 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Declare a friend class inside the class, In friend class it provide desconstructor

- Anonymous October 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

create another function for destroying the static instance and reset it to 0.

- Richa Aggarwal November 11, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Refer to Modern C++ Design for many impl for singleton which handles destruction based on policy. Like what is the Life you want to keep for singleton object and also it tries to handle "static order fiasco" also.

- Maulish May 11, 2011 | Flag Reply


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