Given this code segment:
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String integer = br.readLine(); // CODE System.out.println(val);
Which one of the following statements when replaced by the comment CODE will successfully read an integer value from console?.
a) int val = integer.getInteger(); b) int val = Integer.parseInt(integer); c) int val = String.parseInt(integer); d) int val = Number.parseInteger(integer);
b)
Using the method Integer.parseInt(String) is the correct way to get an int value from a String object. the other three options will not compile.