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.
int words = 1; for (int i = 0; i < s.length(); i++) if (s.charAt(i) == ' ') words++; System.out.println(words);
No citable source has been recorded for this record. Treat it as practice material, not as fact.
The count starts at 1 because a sentence with no space still has one word; the method fails on an empty string or on multiple consecutive spaces.
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
What is the difference between s1 == s2 and s1.equals(s2) for two String references?
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
Write a Java program segment to change the case of every letter of a string s.
String Handling
State and verify the absorption law X + X·Y = X using a truth table.
Boolean Algebra