What will be the result of attempting to compile and run the following program?
public class Main{ public static void main (String args []){ int i = 0; loop : // 1 { // w w w. j a va 2 s. c om System .out.println ("Loop Lable line"); try{ for ( ; true ; i++ ){ if ( i >5) break loop; // 2 } } catch (Exception e){ System .out.println ("Exception in loop ."); } finally{ System .out.println ("In Finally"); // 3 } } } }
Select 1 option
Correct Option is : C
A break without a label breaks the current loop and a break with a label tries to pass the control to the given label.
If the break is in a try block and the try block has a finally clause associated with it then it will be executed.