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:
import java.nio.*;
public class ReadTemps {
public ReadTemps() {
int[] temperatures = { 78, 80, 75, 70, 79, 85, 92, 99, 90, 85, 87 };
IntBuffer tempBuffer = IntBuffer.wrap(temperatures);
int[] moreTemperatures = { 65, 44, 71 };
tempBuffer.put(moreTemperatures);
System.out.println(“First int: “ + tempBuffer.get());
}
17
}
What will be the output when this application is run?
a. First int: 78
b. First int: 71
c. First int: 70
d. None of the above
The answer is available on the topic's website at http://www.java21days.com. Visit the
Day 17 page and click the Certification Practice link.
Exercises
To extend your knowledge of the subjects covered today, try the following exercises:
1. Write an application that stores some of your favorite web pages on your computer
so that you can read them while you are not connected to the Internet.
2. Write a program that takes finger requests, looks for a .plan file matching the
username requested, and sends it if found. Send a “user not found” message other-
wise.
Where applicable, exercise solutions are offered on the topic's website at http://www.
java21days.com.
 
Search WWH ::




Custom Search