Bloomberg LP Interview Question
Financial Software Developersya... a typical bloomberg interview... not so different from what I had and what I heard.
if you read herb sutter's books then you can easily crack bloomberg's interviews, its probably a bible for them.lol
They are less concerned about how smart you are. all they want how much do you know about the language or technology
Why do we need a private constructor?
It is used to stop creating instance directly through "new" like classA aObj = new classA(); from another class.
As the constructor is private it will through compile time error.
So in this case we can create a static method say .getInstance() where we can initialize the class
static classA getInstance() {
classA obj ;
if(obj == null) {
obj = new classA();
}
return obj;
}
Exactly as we name this as singleton pattern
en . wikipedia . org / wiki / Singleton_pattern
The disadvantage which i feel this has that it will always be existing in the heap and can never be garbage collected as the reference always exist once created.
So kind of good only if you know you are going to use this object at all places example the DB Connection object.
www . theserverside . com / discussions / thread . tss?thread_id=28184
I wouldn't be surprised if they asked you
- anonymousse December 01, 2010"what exceptions are thrown by the functions in Clause 28.8 to report errors?"