Introduction to Programming Using Java — Question 3

You work as a Java programmer.
You need to convert a numeric String to a primitive double value.
What code segment should you use?

Answer options

Correct answer: D

Explanation

The correct answer is D, as Double.parseDouble(numberString) is the proper method to convert a numeric String to a primitive double. Option A returns a Double object instead of a primitive double, while option B is incorrect because 'double' is not a class with a method 'parseDouble'. Option C is also incorrect because String does not have a method named 'parseDouble'.