Bird
0
0

Given a string input, how to create a new string with all vowels removed using common string methods?

hard📝 Application Q8 of 15
Java - Strings and String Handling
Given a string input, how to create a new string with all vowels removed using common string methods?
Ainput.replaceAll("[aeiouAEIOU]", "")
Binput.remove("aeiou")
Cinput.deleteVowels()
Dinput.stripVowels()
Step-by-Step Solution
Solution:
  1. Step 1: Identify method to remove characters by pattern

    replaceAll() with regex can remove vowels by replacing them with empty string.
  2. Step 2: Check other options

    remove(), deleteVowels(), stripVowels() are not valid String methods in Java.
  3. Final Answer:

    input.replaceAll("[aeiouAEIOU]", "") -> Option A
  4. Quick Check:

    Use replaceAll() with regex to remove vowels [OK]
Quick Trick: Use replaceAll("[aeiouAEIOU]", "") to remove vowels [OK]
Common Mistakes:
  • Using non-existent methods
  • Forgetting case-insensitive vowels

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes