Given a sample code:
1 public class Test2 {
2 public static void main(String[] args) {
3 System.out.println("Hello");
4 break;
5 System.out.println("Hi");
}}
What will be result when compiled and run?
(A) Hello
(B) Hello Hi
(C) Runtime exception.
(D) Compilation error at line no-4.
(D)
break cannot be used outside of a loop or a switch
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.