Harman Kadron Interview Question for Java Developers


Country: United States
Interview Type: Phone Interview




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

Stack memory stores primitive types and the addresses of objects.

The object values are stored in heap memory. An object reference on the stack is only an address that refers to the place in heap memory where that object is kept.

- Expressions April 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Expressions is right

- wawa April 04, 2013 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 votes

But if an object contains a primitive type, that primitive type will be on the heap. So not all primitives are stored on the stack. I'm not sure whether that is or is not what you meant in your answer.

- eugene.yarovoi April 04, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Yes the primitive data types inside an object are part of the object hence would be on heap.

- Expressions April 04, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Primitive data types are stored in stack unless they are part of an object.Objects/instances are stored on heap and if Objects/Instances contains primitive data types then in this case primitive data types are stored on heap

- kedarsdixit April 04, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Primitive data types stored in stack memory.
Object stored in Heap memory. * Reference for the object stored in the Stack point to the object.

- narendra.kesineni June 22, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

HEAP

- Krishna K Tiwari April 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

but if it is inside a method, isnt it to be in a stack??

- ab April 03, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Primitive always be in stack and object goes to Heap. Let me know if I am wrong.

- Geet April 03, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Primitive data types are stored in stack unless they are part of an object.Objects/instances are stored on heap and if Objects/Instances contains primitive data types then in this case primitive data types are stored on heap.

- kedarsdixit April 04, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

When a method is called , a frame is created on the top of stack.
Once a method has completed execution , flow of control returns to the calling method and its corresponding stack frame is flushed.
Local variables are created in the stack
Instance variables are created in the heap & are part of the object they belong to.
Reference variables are created in the stack.

- surya April 04, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think it should be in the heap .

- Engineer1111 April 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The storage of primitive data types depends upon the type of the variable.
If the variable is a local variable whose scope is with in the method then it is stored in "stack".
If the variable is a static variable whose scope the entire class then it is stored in the "Class context area",where as if the variable is a non static variable whose scope is with in the object then it is stored in the "Heap"

- balaji May 28, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It does not depend on whether it is a primitive data type or not, It depends on whether it is an Instance variable or a local variable.
All local variables are stored in the stack along with their methods within which they are declared.
All instance variables/objects which contain primitive types are stored on the heap even if they are declared inside a method.Only their references stay in the stack if declared inside a method.

- pooja September 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You can clear many of your doubts regarding data types in Core Java through Merit Campus, visit:Merit Campus.

- Merit Campus February 11, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Through Merit Campus, you can get an solution to all your doubts. Kindly visit Merit Campus

- Merit Campus February 11, 2016 | 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