A Java programmer has written the following method that takes an array of integers and sums up all the integers that are less than 100.
public class Main { public static void processArray(int[] values) { int sum = 0; int i = 0;//from w ww . j a va2 s . com try { while (values[i] < 100) { sum = sum + values[i]; i++; } } catch (Exception e) { } System.out.println("sum = " + sum); } public static void main(String args[]) { int[] a = { 1, 2, 3, 4, 5 }; processArray(a); } }
Which of the following are best practices to improve this code?
Select 2 options
Correct Options are : B D
Empty catch blocks are a bad practice.
At run time, if the exception is thrown, the program will not show any sign of the exception.