Write a Java program segment to print the first letter of every word of a sentence s with single spaces between words.
String Handling
Original Khojo Papers practice question — not from a past board paper.
An immutable object cannot be changed after it is created; any method that appears to modify a String in fact returns a new String and leaves the original untouched. StringBuffer, or StringBuilder, should be used when the contents must be changed in place.
No citable source has been recorded for this record. Treat it as practice material, not as fact.
Immutability is what makes it safe for Java to share identical string literals.
From the same topic and chapter, at a similar level.
Write a Java program segment to print the first letter of every word of a sentence s with single spaces between words.
String Handling
What is the output of: String s = "Examination"; System.out.println(s.length() + " " + s.substring(0, 4) + " " + s.toUpperCase().charAt(2));
String Handling
What is the output of: String s = "Computer"; System.out.println(s.substring(2, 5) + s.length() + s.charAt(0));
String Handling
Write a Java program segment to check whether a given string s is a palindrome.
String Handling
Explain the ternary operator in Java and rewrite "if (a > b) max = a; else max = b;" using it.
Operators and Expressions in Java
Reduce the Boolean expression X·Y + X·Y′ using the laws of Boolean algebra.
Boolean Algebra