Siemens Interview Question for Software Engineer / Developers






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

I am not sure I understand your question . Can you be more precise ?

- Anonymous August 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

I guess the question is: Why doesn't a swap method works for objects?
Ans: It is because, everything in Java is pass by value. So by swapping objects we are only trying to swap references(assuming object's are passed in the method as parameters), which is not possible in Java. Hence, it doesn't work.

- Anonymous September 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

We are passing copy of references as arguments to the method. Method manipulates the copies of references but not original reference.

public class PassByReference
{
public static void main(String args[])
{
String st = new String("hi");
method(st);
System.out.println(st);
}
//here q is another reference to 'hi' object
static void method(String q)
{
System.out.println(q);
q = new String("bye");
}
}

- raghava.javvaji September 23, 2012 | 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