Question | Answer | Explanation |
A value must always be assigned to String object when it is created, and cannot be modified later. True
False
| False | The text in Strings objects can be changed unless they are declared as final. |
The expression str.length returns the length (number of characters) contained in str, a String object. True
False
| False | 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? |
The System.in and System.out objects are created by default and need not be created explicitly. True False
| True | System.in and System.out are static objects in the class System that allow reading and writing from and to the console. |
An instance of the java.io.File class can be used to delete a file. True False
| True | The class java.io.File supports the method delete which can be used to delete a file or a directory. |
An instance of class java.awt.Panel cannot be added to another instance of the same class. True
False
| False | Panels are useful to create layouts of a graphic object, and can be placed inside other panels. |
The CheckboxGroup class in package java.awt is a subclass of the Component class in the same package. True
False
| False | An instance of CheckboxGroup may be used to group together instances of Checkbox class. It is by itself not a Component. |
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
| True | GridLayout simply divides the available space into rectangles of equal dimensions. |
The BorderLayout class in java.awt is intended mainly to allow decorative borders to be laid out around graphic components. True
False
| False | The BorderLayout class can be used to lay out components in a graphic object in 5 different locations NORTH, SOUTH, EAST, WEST and CENTER. |
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
False
| False | The class java.io.File provides functionality to list contents of a directory using the list method. |
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
False
| False | The FileReader class provides a convenient way of reading character files in the default character encoding. |