Brainware Interview Question for Software Engineer / Developers






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

No.. Java supports both call by value and call by reference.. When primitive types are passed to a function they are passed by value.Objects are always passed call by reference and when u pass reference explicitly then call by value takes place.

- tadivijaykumar July 15, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In Java, its always call by reference

- AB July 15, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

wrong

- running July 24, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Java is strictly call by value. Objects only location of the obj on heap is passed. so when you edit it method the object in heap is modified.

- Anonymous July 15, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

with implementation perspective its always call by value.

- Dinesh July 17, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Everything is by value. But note that when you declare an object, the variable is really a reference. Java passes object references by value.

Object obj = new Object();

Here obj is an object reference, and this reference is passed by value (copy of the reference is created) when passed to a method.

- rk July 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

java supports only call by value.

but I have read many a times that base data types are send to a funtion by value while objects are send by refernce

- kamal August 03, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

it is call by value always.
for primitives, copies of the values are sent.
for objects, copies of the reference is sent.
public void method( object ref)
{
ref= new Object();// when the method finishes, you main method will still have the ref
to the original object..

}

- anon August 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

String is an object in java and immutable. Then how the string passed "pass by value" or "pass by reference"?

- Nagesh January 02, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Like any other Object in Java, a String object is also passed by value (value of the reference to String object is passed). This by no means defeat immutable nature of String objects - that is, if inside the method, you try to change the string object, it will still create a new String object for the modified string either in heap (if creates using new String() constructor) or String constant pool (otherwise).

- Ravi February 15, 2012 | Flag


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