Citigroup Interview Question for Applications Developers


Country: India




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

As people have already stated above, all four objects: MyClass, MyObject, String data and "ddd" are created in Heap area. In fact there is no way an object can be "created" in stack area. Nevertheless, variable 'i' would be created in the stack of mehtod().

- Nawazish October 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I would like to add the following to my answer above: It does not matter whether "Thread" indirectly creates an object or JVM, objects would always be created in the Heap area only.

- Nawazish October 15, 2013 | Flag
Comment hidden because of low score. Click to expand.
3
of 3 vote

Object is allocated in Heap, but reference push to the stack. Also you should know that each thread has his own stack.

- glebstepanov1992 October 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Except for int i=10, all other objects are created in heap and a pointer to them is maintained in the stack ... i is created directly in stack and once it goes out of scope it is popped off ...

- Jack October 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Object always goes to heap memory.
Threads have individual stacks, so reference variable goes to thread's stack.
This variables refers to the object in the heap

- meexplorer11 October 14, 2013 | 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