Walmart Labs Interview Question for Software Engineers


Country: United States




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

Please add more details about the question...the question is not clear....

- varun.me15 March 30, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

changed the question..

- MrA March 30, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Can please someone explain why my answer was downvoted?

- varun.me15 March 30, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

It should print out "1"

The thread is started when you call thread.start().
Now there are 2 threads running - the original one that called start, and t.
t will wait until the boolean is set to true in the original thread, then print out "1". Thread t then ends.

- Skor March 30, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The answer is indeterminate.

The spawning thread sets MyClass.flag to true, then updates MyClass.num without any synchronization. Thus MyThread might awaken and execute at any point between or after MyClass sets MyClass.num -- or even during.

- auricoso2000 March 30, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Output depends on the behavior of the scheduler.

- Sahil March 30, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Output should be 10.Because while statement never execute.Whereas MyClass.num=10;

- md ishtiyaque April 01, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

output will be 10. bcoz yield() basically means that the thread is not doing anything particularly important and if any other threads or processes need to be run, they should. Otherwise, the current thread will continue to run

- rajatcoolduden April 05, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

System.out.println(My Class.num + My Class.flag) ;

- Raji June 25, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Answer is 10 coz thread t will wait for the main thread to execute and set the num variable to 10, before t continues further execution.

- amith November 08, 2015 | 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