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.
mpu8C
No citable source has been recorded for this record. Treat it as practice material, not as fact.
substring(2, 5) returns the characters at positions 2, 3 and 4, that is "mpu"; length() is 8; and charAt(0) is C. The + operator concatenates because the first operand is a String.
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
Explain what is meant by saying that String objects in Java are immutable, and name the class to use when a mutable string is needed.
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