Bloomberg LP Interview Question

  • bloomberg-lp-interview-questions
    0
    of 0 votes
    8
    Answers

    class A {};

    void foo()
    {

    throw new A;

    }

    Which of the following catch statement is valid?

    choice a:
    catch (A && e)

    choice b:
    catch (A e)

    choice c:
    catch (A * e)

    choice d:
    catch (A ** e)

    choice e:
    catch (A & e)

    - c.c. on December 11, 2009 Report Duplicate | Flag
    Bloomberg LP C++



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

c

- Anonymous on December 13, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Since new returns a pointer , so the result should be a pointer of type A.
Choice C should be correct.

- Musheka on December 16, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

You are right. Here catch need to receive a pointer, because new A return a pointer.

- Anonymous on February 15, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

E works, C fails.

- Henry on January 20, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

C works. Copy the following code and check.

#include<iostream>
#include<iomanip>

using namespace std;

class A {};

void foo()
{

throw new A;


}

int main()
{

try
{
foo();
}
catch (A * e)
{
cout<< "c works";
}

catch (A & e)
{
cout<< "e works";
}
return 0;
}

- Shiva on February 11, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Pls check by coding, C works. who said C fails. My goodness.

- what are you guys doing? on March 03, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

C works and C rocks n so do I :)

- Gaurav Singh on November 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

E is right.

- Anonymous on January 20, 2010 | Flag Reply


Add a Comment
Name:

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

Books

is a comprehensive book walking you through every aspect of getting a job at a top tech company, while focuses on software engineering interviews.

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