Interview Question for Software Engineer / Developers


Team: Java Developer
Country: Nepal
Interview Type: In-Person




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

I don't know about console colors, but IIRC standard error stream is flushed automatically while standard output is not. So if both stderr and stdout are directed to the console, the output is likely to be
0 2 4 6 8 10 12 .. 98 100 1 3 5 7 9 11 .. 97 99 (spaces for clarity)

- Miguel Oliveira October 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

+1
but std output buffer might be nearly full...
it might flush before all the odd numbers in that for loop are dealt with

i don't think it can be predicted without knowing the rest of the program (before this bit of code is called)

- S O U N D W A V E October 07, 2013 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 vote

You can not predict the output. It will print the numbers in random order and color will depend on the consoles

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

agree on cannot be predicted +1

don't agree on random

- S O U N D W A V E October 07, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 3 vote

The order of elements to be print is not determined, because we write them to different streams. Each will be flushed in it's own time. So we will get different results.

- gstepanov@griddynamics.com October 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

in a Windows command line error and output streams are flushed as they're printed. The result is thus:
012345678910111213... till 100

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

02468101214161820222426283032343638404244464850525456586062646668707274767880828486889092949698100
13579111315171921232527293133353739414345474951535557596163656769717375777981838587899193959799

- Anonymous February 06, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

it will give
99
100

As we are over writing value of i in every loop.For 99,it will go to else part and print 99.For 100,it goes to if part and replace i.

- Anonymous June 26, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

it will give
99
100

As we are over writing value of i in every loop.For 99,it will go to else part and print 99.For 100,it goes to if part and replace i.

- shelly June 26, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.


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