R

Ranjeet • 34.60K Points
Instructor I

Q. What is the result of the following code snippet?

try {
int num = 10 / 0;
} catch (ArithmeticException e) {
System.out.println("Arithmetic Exception!");
} catch (Exception e) {
System.out.println("Exception!");
}

  • (A) Exception!
  • (B) No output
  • (C) Compilation error
  • (D) Arithmetic Exception!
  • Correct Answer - Option(D)
  • Views: 25
  • Filed under category JAVA

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Related MCQs on JAVA

Q. First public implementation of java was

Q. Which of the following statements is true about ArrayLists in Java?

Q. What will be the output of the following Java program? import java.lang.reflect.*; class Additional_packages { public static void main(String args[]) { try { Class c = Class.forName("java.awt.Dimension"); Constructor constructors[] = c.getConstructors(); for (int i = 0; i < constructors.length; i++) System.out.println(constructors[i]); } catch (Exception e) { System.out.print("Exception"); } } }

Q. Determine output: public class Test{ public static void main(String args[]){ String s1 = "SITHA"; String s2 = "RAMA"; System.out.println(s1.charAt(0) > s2.charAt(0)); } }

Q. What method is used to convert an integer to a string in Java?

Q. What is the output of the following code? public class Test{ public static void main(String args[]){ double[] myList = {1, 5, 5, 5, 5, 1}; double max = myList[0]; int indexOfMax = 0; for(int i = 1; i < myList.length; i++){ if(myList[i] > max){ max = myList[i]; indexOfMax = i; } } System.out.println(indexOfMax); } }

Q. Which of these method of class String is used to extract a single character from a String object?

Q. How do you indicate where a component will be positioned using Flowlayout?

Q. What is the expected output? public class Profile { private Profile(int w) { // line 1 System.out.print(w); } public static Profile() { // line 5 System.out.print (10); } public static void main(String args[]) { Profile obj = new Profile(50); } }

Q. Which cookie it is valid for single session only and it is removed each time when the usercloses the browser?

Learn All JAVA MCQs


Question analytics