Practice question
3 marksWrite a Java program segment to count the words in a sentence s that has single spaces between words.
String HandlingMediumApplication based
Computer Science · Class 12 · ISC
String and StringBuffer, string methods, and palindrome, anagram and word-level problems.
6questions
Syllabus mapping: ISC syllabus (CISCE) (opens CISCE's website in a new tab)
6 questions
Practice question
3 marksWrite a Java program segment to count the words in a sentence s that has single spaces between words.
String HandlingMediumApplication based
Practice question
3 marksState three differences between the String and the StringBuffer classes.
String HandlingMediumShort answer
Practice question
3 marksWrite a Java program segment to count the number of vowels in a given string s.
String HandlingMediumApplication based
Practice question
3 marksWhat is the output of: String s = "Programming"; System.out.println(s.indexOf('g') + " " + s.lastIndexOf('g') + " " + s.replace('g', 'G'));
String HandlingMediumNumerical
Practice question
3 marksWhat is the difference between s1 == s2 and s1.equals(s2) for two String references?
String HandlingMediumNumerical
Practice question
3 marksWrite a Java program segment to change the case of every letter of a string s.
String HandlingMediumApplication based