Friday, August 16, 2019

What is the output of the following code?

Problem statement:
Given the code of java. Find out 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. } catch (RuntimeException ex) {
  14. System.out.println("runtime");
  15. }
  16.     System.out.println("end");
  17. }
  18. }
Output:
test
exception
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...