Java Reference
In-Depth Information
Certification Practice
The following question is the kind of thing you could expect to be asked on a Java pro-
gramming certification test. Answer it without looking at today's material or using the
Java compiler to test the code.
Given:
public class CharCase {
public static void main(String[] arguments) {
float x = 9;
float y = 5;
char c = '1';
switch (c) {
case 1:
x = x + 2;
case 2:
x = x + 3;
default:
x = x + 1;
}
System.out.println(“Value of x: “ + x);
}
}
What will be the value of x when it is displayed?
a. 9.0
b. 10.0
c. 11.0
d. The program will not compile.
The answer is available on the topic's website at http://www.java21days.com. Visit the
Day 21 page and click the Certification Practice link.
Exercises
To extend your knowledge of the subjects covered today, try the following exercises:
1. Create a servlet that stores the data entered in a form in a file.
2. Write a JSP page that displays one greeting for Microsoft Internet Explorer users
and another greeting for everyone else.
21
Where applicable, exercise solutions are offered on the topic's website at http://www.
java21days.com.
 
Search WWH ::




Custom Search