Which modification enables the code fragment to print TrueDone?
1. Replace line 5 With String result = "true"; Replace line 7 with case "true": 2. Replace line 5 with int opt = l; Replace line 7 with case 1 :
3. At line 9, remove the break statement. 4. Remove the default section.
Correct Answer : 2
Question : Given the code fragment: Which modification enables the code to print 54321? 1. Replace line 6 with System, out. print (x--) ; 2. At line 1, insert x --; 3. Replace line 6 with --x; and, at line 7, insert system, out. print (x); 4. Replace line 12 With return (x > 0) ? false: true;
Correct Answers: 1 Explanation:
Question : Given the code fragment: What is the result? 1. Reading Card Card 2. Compilation fails only at line n1. 3. Compilation fails only at line n2. 4. Compilation fails only at line n3. 5. Compilation fails at both line n2 and line n3.
Correct Answer : 4
Explanation: There is no need to catch RuntimeException . However, Exception or any subclass of Exception you have to catch (These are checked exception)