What is the result? 1. Execution terminates in the first catch statement, and caught a RuntimeException is printed to the console 2. Execution terminates In the second catch statement, and caught an Exception is printed to the console. 3. Access Mostly Uused Products by 50000+ Subscribers 4. Execution completes normally, and "Ready to use" is printed to the console. 5. The code fails to compile because a throws keyword is required.
Correct Answer : Get Lastest Questions and Answer Explanation: After running the program below error will be printed. Reason : there is a infinite while loop while(true), which keeps adding a String object in List and never exit. Which causes this error.
Exception in thread "main" java.lang.outofMemoryError: Java heap space at java.util.Arrays.copyof(Arrays.java:3210) at java.util.Arrays.copyof(Arrays.java:3181) at java.util.ArrayList.grow(ArrayList.java:261) at java.util.ArrayList.ensureExplicitCapacity(ArrayList.java:235) at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:227) at java.util.ArrayList.add(ArrayList.java:458) at Q45.main(Q45.java:11) Java Result: 1
Question : When you run the given program, what would be printed.
Correct Answer : Get Lastest Questions and Answer : Explanation: StringBuilder(int capacity) Constructs a string builder with no characters in it and an initial capacity specified by the capacity argument. Note: An instance of a StringBuilder is a mutable sequence of characters. The principal operations on a StringBuilder are the append and insert methods, which are overloaded so as to accept data of any type. Each effectively converts a given datum to a string and then appends or inserts the characters of that string to the string builder. The append method always adds these characters at the end of the builder; the insert method adds the characters at a specified point.
Question : You have been given code as shown, what happen when you compile/run