LearnFrenzy
Sign in Take a free test

Object Class and Wrapper Classes · Object and Wrapper Classes MCQ · Question 14

parseInt versus valueOf Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 14 Back to Exercise

What is the difference between Integer.parseInt(s) and Integer.valueOf(s)?

  • A None
  • B parseInt returns a primitive int; valueOf returns an Integer object Correct
  • C valueOf throws no exceptions
  • D parseInt works only for hex
Correct Answer: Option B

Both throw NumberFormatException for invalid text.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links