Q54
Which operators will always evaluate all the operands?
1) ||
2) +
3) &&
4) ? :
5) %
Q55
Which statements concerning the switch construct are true?
1) All switch statements must have a default label.
2) There must be exactly one label for each code segment in a switch statement.
3) The keyword continue can never occur within the body of a switch statement.
4) No case label may follow a default label within a single switch statement.
5) A character literal can be used as a value for a case label.
Q56
Which modifiers and return types would be valid in the declaration of a working main() method for a Java standalone application?
1) private
2) final
3) static
4) int
5) abstract
Q57
What will be the appearance of an applet with the following init() method?
public void init() {
add(new Button("hello"));
}
1) Nothing appears in the applet.
2) A button will cover the whole area of the applet.
3) A button will appear in the top left corner of the applet.
4) A button will appear, centered in the top region of the applet.
5) A button will appear in the center of the applet.
Q58
Which statements concerning the event model of the AWT are true?
1) At most one listener of each type can be registered with a component.
2) Mouse motion listeners can be registered on a List instance.
3) There exists a class named ContainerEvent in package java.awt.event.
4) There exists a class named MouseMotionEvent in package java.awt.event.
5) There exists a class named ActionAdapter in package java.awt.event.
Q59
Which statements are true, given the code new FileOutputStream("data", true) for creating an object of class FileOutputStream?
1) FileOutputStream has no constructors matching the given arguments.
2) An IOExeception will be thrown if a file named "data" already exists.
3) An IOExeception will be thrown if a file named "data" does not already exist.
4) If a file named "data" exists, its contents will be reset and overwritten.
5) If a file named "data" exists, output will be appended to its current contents.
Q60
Given the following code, write a line of code that, when inserted at the indicated location, will make the overriding method in Extension invoke the overridden method in class Base on the current object.
class Base {
public void print() {
System.out.println("base");
}
}
class Extention extends Base {
public void print() {
System.out.println("extension");
// insert line of implementation here
}
}
public class Q294d {
public static void main(String args[]) {
Extention ext = new Extention();
ext.print();
}
}
Fill in a single line of implementation.
Q61
Given that file is a reference to a File object that represents a directory, which code fragments will succeed in obtaining a list of the entries in the directory?
1) Vector filelist = ((Directory) file).getList();
2) String[] filelist = file.directory();
3) Enumeration filelist = file.contents();
4) String[] filelist = file.list();
5) Vector filelist = (new Directory(file)).files();
Q62
What will be written to the standard output when the following program is run?
public class Q03e4 {
public static void main(String args[]) {
String space = " ";
String composite = space + "hello" + space + space;
composite.concat("world");
String trimmed = composite.trim();
System.out.println(trimmed.length());
}
}
1) 5
2) 6
3) 7
4) 12
5) 13