Tricky Java Interview Questions - Part 1
Hi Folks, any java interview you go there will definitely be certain tricky question they tend to ask and sometimes even to write the program in a white board. Here im planning to bring all those questions together in one page, so that i can be helpful for me and also you guys to refer once before the interview. 1. I had this question with a famous MNC in the 1st technical round. They gave me the below code snippet and told to write any thing after this statement and nothing before this. Expected output : Print 1 2 3 .... 100 Code : for(int i=0; i> Working code Answer : for(int i=0; i>=0;) { if(i==100) { break; } System.out.println(++i); } This is pretty simple but can be tough to quickly derive the logic at that point of time. ----------------------------------------------------------------------------------------------------------------------- 2. This question was asked to me during an interview to test not only my java basic programmi