Saturday, August 17, 2019

what will happen when you run the following code?

Problem statement:
Given the java code. what will be the output?
  1. public class Test {
  2. static void test() throws RuntimeException {
  3. try {
  4. System.out.println("test");
  5. throw new RuntimeException();
  6. } catch (Exception ex) {
  7. System.out.println("exception");
  8. }
  9. }
  10. public static void main(String[] args) {
  11. try {
  12. test();
  13. throw new RuntimeException();
  14. } catch (RuntimeException ex) {
  15. System.out.println("runtime");
  16. System.out.println("end");
  17. }
  18. }
  19. }
Output:
test
exception
runtime
end

No comments:

Post a Comment

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...