To convert a String to a Number in a Java program, the function used is the valueOf()
function.
Let's go through each option to understand why it is correct or incorrect:
Option A) toNumber() - This option is incorrect because there is no built-in function in Java called toNumber()
.
Option B) conString() - This option is incorrect because the function name does not suggest any conversion from a String to a Number.
Option C) valueOf() - This option is correct because the valueOf()
function is a built-in function in Java that can be used to convert a String to a Number.
Option D) None of the Above - This option is incorrect because the correct answer is option C) valueOf().
The correct answer is C) valueOf(). This option is correct because it is the function used to convert a String to a Number in a Java program.