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.
The == operator compares the two references and is true only if both point at the same object. The equals method compares the contents of the two strings character by character. For string literals == may accidentally be true because of the string pool, which is why equals must always be used.
No citable source has been recorded for this record. Treat it as practice material, not as fact.
compareTo returns the difference and is used for ordering.
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
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