Answer the following questions about the Java programming language API (applications programming interface). A knowledge of basic classes in the java.lang, java.awt and java.io packages is recommended.
1. A value must always be assigned to String object when it is created, and cannot be modified later. True
The text in Strings objects can be changed unless they are declared as final.
2. The expression str.length returns the length (number of characters) contained in str, a String object. True
The method str.length() must be invoked to obtain the length of a string. Food for thought: if str was an array of String objects instead of a String object, what would str.length return?
3. The System.in and System.out objects are created by default and need not be created explicitly. True False
System.in and System.out are static objects in the class System that allow reading and writing from and to the console.
4. An instance of the java.io.File class can be used to delete a file. True False
The class java.io.File supports the method delete which can be used to delete a file or a directory.
5. An instance of class java.awt.Panel cannot be added to another instance of the same class. True
Panels are useful to create layouts of a graphic object, and can be placed inside other panels.
6. The CheckboxGroup class in package java.awt is a subclass of the Component class in the same package. True
An instance of CheckboxGroup may be used to group together instances of Checkbox class. It is by itself not a Component.
7. If an instance of the GridLayout class in java.awt package is used as a layout manager for a java.awt.Frame object, then all the components added directly to the Frame object are of the same width and height. True False
GridLayout simply divides the available space into rectangles of equal dimensions.
8. The BorderLayout class in java.awt is intended mainly to allow decorative borders to be laid out around graphic components. True
The BorderLayout class can be used to lay out components in a graphic object in 5 different locations NORTH, SOUTH, EAST, WEST and CENTER.
9. As a part of the standard API, Java provides a class called Directory in the package java.io which enables the listing of the contents of a directory. True
The class java.io.File provides functionality to list contents of a directory using the list method.
10. Java makes it easy to read floats and doubles by providing methods to accomplish this in its FileReader class in the package java.io. True
The FileReader class provides a convenient way of reading character files in the default character encoding.