← Quiz: Java Data Types: all 10 questions
Quiz: Java Data Types · Question 5 of 10
Which converts the String "42" into an int?
Which converts the String "42" into an int?
- A.(int) "42"
- B.Integer.parseInt("42")
- C.String.toInt("42")
- D.int.parse("42")
Answer & explanation
Correct answer: Integer.parseInt("42")
Integer.parseInt parses text into an int. You cannot cast a String to int.
Can you get the rest right without peeking?
Take the timed Quiz: Java Data Types quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →