What is the output of: String s = "Programming"; System.out.println(s.indexOf('g') + " " + s.lastIndexOf('g') + " " + s.replace('g', 'G'));
String Handling
Original Khojo Papers practice question — not from a past board paper.
String r = ""; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (Character.isUpperCase(c)) r += Character.toLowerCase(c); else if (Character.isLowerCase(c)) r += Character.toUpperCase(c); else r += c; }
No citable source has been recorded for this record. Treat it as practice material, not as fact.
Characters that are not letters must be copied through unchanged.
From the same topic and chapter, at a similar level.
What is the output of: String s = "Programming"; System.out.println(s.indexOf('g') + " " + s.lastIndexOf('g') + " " + s.replace('g', 'G'));
String Handling
Write a Java program segment to count the words in a sentence s that has single spaces between words.
String Handling
Write a Java program segment to count the number of vowels in a given string s.
String Handling
State three differences between the String and the StringBuffer classes.
String Handling
What is the difference between s1 == s2 and s1.equals(s2) for two String references?
String Handling
State and verify the absorption law X + X·Y = X using a truth table.
Boolean Algebra