Java Reference
In-Depth Information
Display 5.9
String Processing with a Method from the Class Character (part 2 of 2)
Sample Dialogue
Enter a one line sentence:
is you is OR is you ain't my BABY?
The revised sentence is:
Is you is or is you ain't my baby?
Self-Test Exercises
20. What is the output produced by the following code?
Character characterObject1 = new Character('a');
Character characterObject2 = new Character('A');
if (characterObject1.equals(characterObject2))
System.out.println("Objects are equal.");
else
System.out.println("Objects are Not equal.");
21. Suppose result is a variable of type double that has a value. Write a Java expression
that returns a string that is the normal way of writing the value in result .
22. Suppose stringForm is a variable of type String that names a String that
is the normal way of writing some double , such as "41.99" . Write a Java
expression that returns the double value named by stringForm .
23. How would you do Exercise 22 if the string might contain leading and/or
trailing blanks, such as " 41.99 " ?
24. Write Java code to output the largest and smallest values of type long allowed
in Java.
25. How do you create an object of the class Character that corresponds to the
letter 'Z' ?
26.
Does the class Character have a no-argument constructor?
5.2
References and Class Parameters
Do not mistake the pointing finger for the moon.
ZEN SAYING
Variables of a class type and variables of a primitive type behave quite differently in
Java. Variables of a primitive type name their values in a straightforward way. For
 
 
 
Search WWH ::




Custom Search