Core Java - Interview Questions and Answers for 'Break' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Core Java - Interview Questions and Answers for 'Break' - 5 question(s) found - Order By Newest

 Q1. What will happen if we don't have termination statement in recursion ?
Ans. Function call allocates a stackframe in stack. Every stackframe will use some memory to store local variables, parameters and to remember return address. Without terminating condition stackframes will keep consuming memory from stack and eventually program will result in stackoverflow error.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     recursion   break statement  break  stackoverflow exception  stackoverflow  memory management  memory  exceptions


 Q2. What are the considerations to be made in case of loops in Java ?Core Java
Ans. 1. It shouldn't result in infinite loop. Please make sure that you have a condition that will terminate the loop and that condition should be reached.

2. Make sure to use the break statement if you aspire to only look for something. Not using break will unnecessarily execute it till the end of for loop in some cases.

3. Similarly use continue to execute the loop with next iteration and bypass the rest of the code block if required.

4. Try to avoid multiple nesting of for loops. If it''s required, Make sure to use break and continue properly so as to avoid some unnecessary processing.

5. Make sure to use try catch within the loop and not outside the for loop if you expect it to continue if one of the iteration fails.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   loops   continue   break   for loop  control statements  loop statement.while loop  control statements  loop statement   architecture


 Q3. What is the difference between a break statement and a continue statement?Core Java
Ans. Break statement results in the termination of the statement to which it applies (switch, for, do, or while). A continue statement is used to end the current loop iteration and return control to the loop statement.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   break   continue   loop   for loop  control statements  loop statement   while loop  control statements  loop statement   break   continue   difference between   basic interview question      basic        frequent


 Q4. What is the difference between return and break statement ?Core Java
Ans. return is used within a method to return control out of the method. It may be followed by a value which is returned from the method to calling method immediately preceding the point of call.

break statement is used within a loop to move control out of the loop.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     return statement  break statement  return vs break


 Q5. In the following code, which text will get printed immediately after Hello

for(int countx=0;countx<10;count++){
System.out.println("World");
for(int countx=0;countx<10;count++){
System.out.println("Friend");
for(int countx=0;countx<10;count++){
System.out.println("Hello");
break;
}
System.out.println("Buddy");
}
}
Core Java
 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     break statement



Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: