Multiple choice

Which of the following statement(s) is/are correct? A. valueOf() is a static method. B. toString() is overridden in Integer and Double Class.

  1. Only A

  2. Only B

  3. Both A and B

  4. Neither A nor B

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Both the statements are correct. The methods valueOf() and toString() belong to String class. The valueOf() method is a static method, so it is always called by using the class name String and the method toString() is overridden in wrapper classes, such as Integer and Double.