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.
String r = ""; for (int i = s.length() - 1; i >= 0; i--) r += s.charAt(i); if (s.equalsIgnoreCase(r)) System.out.println("Palindrome"); else System.out.println("Not a palindrome");
No citable source has been recorded for this record. Treat it as practice material, not as fact.
equals compares contents while == compares references, so equals or equalsIgnoreCase must be used here.
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
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
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