?? mockcert02.txt
字號(hào):
What is the permanent effect on the file system of writing data to a new FileWriter("report"), given the file report already exists?
Mutiple:
1) The data is appended to the file
2) The file is replaced with a new file
3) An exception is raised as the file already exists
4) The data is written to random locations within the file
Question 29
===========================================================
What is the effect of adding the sixth element to a vector created in the following manner:
new Vector(5, 10);
Mutiple:
1) An IndexOutOfBounds exception is raised.
2) The vector grows in size to a capacity of 10 elements
3) The vector grows in size to a capacity of 15 elements
4) Nothing, the vector will have grown when the fifth element was added
Question 30
===========================================================
What is the result of executing the following code when the value of x is 2:
switch (x) {
case 1:
System.out.println(1);
case 2:
case 3:
System.out.println(3);
case 4:
System.out.println(4);
}
Only One:
1) Nothing is printed out
2) The value 3 is printed out
3) The values 3 and 4 are printed out
4) The values 1, 3 and 4 are printed out
Question 31
===========================================================
Consider the following example:
class First {
public First (String s) {
System.out.println(s);
}
}
public class Second extends First {
public static void main(String args []) {
new Second();
}
}
What is the result of compiling and running the Second class?
Only One:
1) Nothing happens
2) A string is printed to the standard out
3) An exception is raised at runtime stating that there is no null parameter constructor in class First.
4) An instance of the class Second is created
5) The class second will not compile as there is no null parameter constructor in the class First
Question 32
===========================================================
What is the result of executing the following fragment of code:
boolean flag = false;
if (flag = true) {
System.out.println("true");
}else{
System.out.println("false");
}
Only One:
1) true is printed to standard out
2) false is printed to standard out
3) An exception is raised
4) Nothing happens
Question 33
===========================================================
Consider the following classes:
public class Test {
public static void test() {
this.print();
}
public static void print() {
System.out.println("Test");
}
public static void main(String args []) {
test();
}
}
What is the result of compiling and running this class?
Only One:
1) The class fails to compile stating that the variable this is undefined.
2) The string Test is printed to the standard out.
3) A runtime exception is raised stating that an object has not been created.
4) Nothing is printed to the standard output.
5) An exception is raised stating that the method test cannot be found.
Question 34
===========================================================
Examine the following class definition:
public class Test {
public static void test() {
print();
}
public static void print() {
System.out.println("Test");
}
public void print() {
System.out.println("Another Test");
}
}
What is the result of compiling this class:
Only One:
1) A successful compilation.
2) A warning stating that the class has no main method.
3) An error stating that there is a duplicated method.
4) An error stating that the method test() will call one or other of the print() methods.
Question 35
===========================================================
What is the result of compiling and executing the following Java class:
public class ThreadTest extends Thread {
public void run() {
System.out.println("In run");
suspend();
resume();
System.out.println("Leaving run");
}
public static void main(String args []) {
(new ThreadTest()).start();
}
}
Only One:
1) Compilation will fail in the method main.
2) Compilation will fail in the method run.
3) A warning will be generated for method run.
4) The string "In run" will be printed to standard out.
5) Nothing will happen.
Question 36
===========================================================
Given the following sequence of Java statements
1.StringBuffer sb = new StringBuffer("abc");
2.String s = new String("abc");
3.sb.append("def");
4.s.append("def");
5.sb.insert(1, "zzz");
6.s.concat(sb);
7.s.trim();
Which of the following statements are true:
Mutiple:
1) The compiler would generate an error for line 3.
2) The compiler would generate an error for line 4.
3) The compiler would generate an error for line 5.
4) The compiler would generate an error for line 6.
5) The compiler would generate an error for line 7.
Question 37
===========================================================
What is the result of executing the following Java class:
import java.awt.*;
public class FrameTest extends Frame {
public FrameTest() {
add (new Button("First"));
add (new Button("Second"));
add (new Button("Third"));
pack();
setVisible(true);
}
public static void main(String args []) {
new FrameTest();
}
}
Select from the following options:
Only One:
1) Nothing happens.
2) A runtime exception is generated (no layout manager specified).
3) Only the "first" button is displayed.
4) Only the "second" button is displayed.
5) Only the "third" button is displayed.
Question 38
===========================================================
Consider the following tags and attributes of tags:
1.CODEBASE
2.ALT
3.NAME
4.CLASS
5.JAVAC
6.HORIZONTALSPACE
7.VERTICALSPACE
8.WIDTH
9.PARAM
10.JAR
Which of the above can be used within the <APPLET> and </APPLET> tags?
Mutiple:
1) line 1, 2, 3
2) line 2, 5, 6, 7
3) line 3, 4, 5
4) line 8, 9, 10
5) line 8, 9
Question 39
===========================================================
Which of the following is a legal way to construct a RandomAccessFile:
Mutiple:
1) RandomAccessFile("data", "r");
2) RandomAccessFile("r", "data");
3) RandomAccessFile("data", "read");
4) RandomAccessFile("read", "data");
Question 40
===========================================================
Carefully examine the following code:
public class StaticTest {
static {
System.out.println("Hi there");
}
public void print() {
System.out.println("Hello");
}
public static void main(String args []) {
StaticTest st1 = new StaticTest();
st1.print();
StaticTest st2 = new StaticTest();
st2.print();
}
}
When will the string "Hi there" be printed?
Mutiple:
1) Never.
2) Each time a new instance is created.
3) Once when the class is first loaded into the Java virtual machine.
4) Only when the static method is called explicitly.
Question 41
===========================================================
Which of the following statements are valid, given the following variable declarations: boolean a; boolean b; int c;
Mutiple:
1) (a | b)
2) (a || a)
3) (a ^ b) | c
4) (a & c)
5) (a && c)
Question 42
===========================================================
Which of the following can be applied to constructors:
Mutiple:
1) final
2) static
3) synchronized
4) native
5) None of these.
Question 43
===========================================================
Which of the following retain their preferred size (width and height) when added (individually) to the North section of a container with a BorderLayout (assume that no other components or containers are present in the North section).
Mutiple:
1) TextArea
2) Button
3) TextField
4) Checkbox
5) None. All of these mentioned components will only retain their preferred height.
Question 44
===========================================================
Which of the following are legal names for variables.
Mutiple:
1) _int
2) %large
3) $fred
4) Integer
5) 2much
Question 45
===========================================================
Which of the following are correct ways to create a font.
Mutiple:
1) Font f = new Font("Serif", Font.BOLD, 24);
2) Font f = new Font(Font.SERIF, "Bold", 24);
3) Font f = new Font("Serif", "Bold", 24);
4) Font f = new Font(Font.SERIF, Font.BOLD, 24);
Question 46
===========================================================
Select the correct statements regarding the following piece of code.
File f = new File("c:\\large.txt");
Mutiple:
1) On execution, a file called "large.txt" will be created on the local harddisk.
2) The code fails to compile on a UNIX machine, because the directory separator is not correct.
3) A file is NOT created on the harddisk when this code is executed.
4) An exception is thrown at runtime if the file "large.txt" already exists.
5) The code fails to compile, since this is not a valid constructor for the File class.
Question 47
===========================================================
Which of the following statements are correct regarding the RandomAccessFile class?
Mutiple:
1) An IOException is thrown if the specified file doesn't exist when created using the "r" mode.
2) This class has a method which allows a file to be deleted from the harddisk.
3) It is possible to use this class in conjunction with the DataInputStream class.
4) When used with the "rw" mode, the specified file is created on a diskdrive, if it doesn't already exist.
5) There are methods to read and write primatives (eg, readInt(), writeInt(), etc).
Question 48
===========================================================
Consider the following piece of code and select the correct statement from the following.
1.String s = new String("abcdefgh");
2.s.replace('d', 'q');
3.System.out.println(s)
Only One:
1) The code fails to compile, reporting an error at line 2. Strings are immutable, and therefore a replace() method is meaningless.
2) The code compiles correctly, and displays the text "abcqefgh".
3) The code compiles correctly, and displays the text "abcdefgh".
4) The code compiles, but an exception is thrown when line 2 is executed.
5) The code compiles, but an exception is thrown at line 3.
Question 49
===========================================================
Which of the following keywords can be applied to the variables or methods of an interface.
Mutiple:
1) static
2) private
3) synchronised
4) protected
5) public
Question 50
===========================================================
True or False.
Only Frames can contain menu bars or pull-down menus
Only One:
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -