Return to site
JAVA CERTIFICATION QUESTION: The scope of variables and dividing by zero
=>If a mathematical equation’s arguments aren’t accessible, what happens to the math operation?
·
Given the following two methods, which are declared in the same class:
public static float divide(float arg1, float arg2) throws ArithmeticException { // line n1 return arg1/arg2; } public static void main(String[] args) { try { int arg1 = 10; int arg2 = 0; System.out.printf("Result: %f", divide(arg1, arg2)); } catch (RuntimeException e) { System.out.printf( "Bad arguments: %d and %d", arg1, arg2); // line n2 } }
What is the result? Choose one.
A. Result: Infinity
B. Result: Nan
C. Bad arguments: 10 and 0
D. Compilation fails at line n1.
E. Compilation fails at line n2.
·Ǝ uoᴉʇdo sᴉ ɹǝʍsuɐ ʇɔǝɹɹoɔ ǝɥꓕ