Java Reference
In-Depth Information
Greek-language keyboard and monitor to do this). The disadvantage of the Uni-
code character set is that it sometimes requires more computer memory to store
each character than it would if Java used only the ASCII character set.
Self-Test Exercises
24. What is the output produced by the following?
String verbPhrase = "is money";
System.out.println("Time" + verbPhrase);
25. What is the output produced by the following?
String test = "abcdefg";
System.out.println(test.length());
System.out.println(test.charAt(1));
26. What is the output produced by the following?
String test = "abcdefg";
System.out.println(test.substring(3));
27. What is the output produced by the following?
System.out.println("abc\ndef");
28. What is the output produced by the following?
System.out.println("abc\\ndef");
29. What is the output produced by the following?
String test = "Hello Tony";
test = test.toUpperCase();
System.out.println(test);
30. What is the output of the following two lines of Java code?
System.out.println("2 + 2 = " + (2 + 2));
System.out.println("2 + 2 = " + 2 + 2);
31. Suppose
sam
is an object of a class named
Person
and suppose
increaseAge
is a
method for the class
Person
that takes one argument that is an integer. How do
you write an invocation of the method
increaseAge
using
sam
as the calling
object and using the argument
10
? The method
increaseAge
will change the data
in
sam
so that it simulates
sam
aging by 10 years.