📄 mockcert04.txt
字号:
boolean flag = false;
if (flag = true)
{
System.out.println("true");
}
else
{
System.out.println("false");
}
Only One:
1) The code fails to compile at the "if" statement.
2) An exception is thrown at run-time at the "if" statement.
3) The text "true" is displayed.
4) The text "false" is displayed.
5) Nothing is displayed.
Question 70
===========================================================
Which of the following is not a subclass of java.awt.Component?
Mutiple:
1) Frame
2) Container
3) CheckboxGroup
4) Canvas
5) Applet
Question 71
===========================================================
What is the result when the following piece of code is compiled and executed.
1. public class Calc {
2. public static void main (String args []) {
3. int total = 0;
4.
5 . for (int i = 0, j = 10; total < 30; ++i, --j) {
6. System.out.println(" i = " + i + " : j = " + j);
7.
8. total += (i + j);
9.
10. }
11.
12. System.out.println("Total " + total);
13. }
14. }
Only One:
1) The code fails to compile at line 5, because the variable "j" is not declared correctly.
2) The code fails to compile at line 2, because you can't have a static method in a non-static class.
3) The code compiles correctly, but throws an exception at line 5.
4) The code compiles correctly but throws an exception at line 2.
5) The code compiles correctly and displays the following when executed:
i = 0 : j = 10
i = 1 : j = 9
i = 2 : j = 8
Total 30
Question 72
===========================================================
Which of the following will create a TextField capable of displaying 10 characters, with the initial text "hello"?
Mutiple:
1) TextField t = new TextField("hello", 10);
2) TextField t = new TextField(10, "hello");
3) TextField t = new TextField();
t.setCols(10);
t.setText("hello");
4) TextField t = new TextField();
t.setFieldSize(10);
t.setText("hello");
5) None of the above.
Question 73
===========================================================
What is the effect of adding the sixth element to a Vector created using the following code:
new Vector(5, 10);
Only One:
1) An IndexOutOfBounds exception is thrown.
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, because Vector elements are zero-based.
5) Nothing. This is not a valid way to create a Vector.
Question 74
===========================================================
When is the text "Hi there" displayed?
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();
}
}
Mutiple:
1) Never.
2) Each time a new object of type StaticTest is created.
3) Once when the class is loaded into the Java virtual machine.
4) Only when the main() method is executed.
Question 75
===========================================================
Which of the following are valid ways to assign the value of 5 to a variable of type "int" called testValue?
Mutiple:
1) int testValue = 0x5;
2) int testValue = (int)(2.1F + 3.4D);
3) int testValue = (octal)5;
4) int testValue = (0x0A >> 1);
5) int testValue = (0x0A >>> 1);
Question 76
===========================================================
Which of the following operations will cause an ActionEvent to be generated.
Mutiple:
1) Clicking a checkbox.
2) Selecting an option from a Choice box.
3) Scrolling a scroll bar.
4) Clicking a button.
5) Hitting ENTER when typing in a text field.
Question 77
===========================================================
True or False.
All Listener interfaces are declared as public and void.
Only One:
1) True
2) False
Question 78
===========================================================
True or False.
In a GridLayout, the width and height of all cells are the same.
Only One:
1) True
2) False
Question 79
===========================================================
True or False.
The BorderLayout manager only allows a single component to be added to each sector.
Only One:
1) True
2) False
Question 80
===========================================================
You want to extend the functionality of the String class, and decide that the best approach is to subclass String. Which of the following statements are correct.
Mutiple:
1) The approach fails, because the String class is declared as final and cannot be subclassed.
2) The approach succeeds, and it is therefore possible to override the standard functionality provided by String.
3) The approach fails, because the String class is declared as abstract, and therefore it cannot be subclassed.
Question 81
===========================================================
Which of the following are valid ways to determine the number of elements in an array defined as follows:
int intArray[] = {1,2,3};
Mutiple:
1) intArray.size;
2) intArray.size();
3) intArray.length;
4) intArray.length();
5) intArray.getSize();
Question 82
===========================================================
You have a check box within a panel, and the panel is contained within an applet. There are no other components within the applet.
Using "setBackground(Color.white)", you assign the background colour of the applet to white.
Which of the following statements are true.
Mutiple:
1) The background colour of the panel is white.
2) The foreground colour of the checkbox is the same as the foreground colour of the applet.
3) It is impossible to determine the background colour of the checkbox from the imformation supplied.
4) You can't put a panel inside an applet.
Question 83
===========================================================
Which of the following can be added to a menu?
Mutiple:
1) A panel
2) A button
3) A menu
4) A checkbox
5) A menubar
Question 84
===========================================================
You construct an application by making the following call:
Frame app = new Frame();
app.setSize(100,100);
Which of the following statements are correct.
Mutiple:
1) An empty frame of size 100x100 is displayed, located in the top left corner of the screen.
2) An empty frame of size 100x100 is displayed, located in the centre of the screen.
3) Nothing is displayed. There is no setSize() method in the Frame class.
4) Nothing is displayed. The frame will only be displayed by setting the forground and background colours.
5) Nothing is displayed. A frame is created by default with zero size, and invisible.
Question 85
===========================================================
Which of the following are valid methods in the java.awt.Graphics class?
Mutiple:
1) drawString()
2) drawOval()
3) fillRect()
4) drawPolyline()
5) fillPolyline()
Question 86
===========================================================
Which of the following are valid command line options for the JAR utility:
Mutiple:
1) c (create a new or empty archive)
2) m (indicates that first argument is the name of a user-supplied manifest)
3) M (do not create a manifest)
4) z (ZIP the contents of the archive)
5) L (list the archive contents)
Question 87
===========================================================
Consider the following code segment and select the correct statement(s):
1. class FinalTest{
2. final int q;
3. final int w = 0;
4.
5. FinalTest(){
6. q = 1;
7. }
8.
9. FinalTest(int x){
10. q = x;
11. }
12. }
Mutiple:
1) The code fails to compile because a class cannot have more than 1 constructor.
2) The code fails to compile because the class FinalTest has no constructors.
3) The code fails to compile because the an attempt is made to initialise a final variable at lines 6 and 10.
4) The code compiles correctly without any warnings or errors.
5) The code fails to compile because the final variable q is not initialised correctly at line 2.
Question 88
===========================================================
True or False.
It is valid to throw (and re-throw) an exception inside a catch{} clause.
For example:
...
catch (Exception e){
throw e;
}
Only One:
1) True
2) False
Question 89
===========================================================
True or False.
A scrollbar will appear in a TextField if more text is typed than can be displayed within the TextField.
Only One:
1) True
2) False
Question 90
===========================================================
True or False.
It is valid to declare an inherited method as abstract.
Only One:
1) True
2) False
Question 91
===========================================================
Consider the following code segments and select the correct statement:
Segment 1:
1. int a = 3;
2. int b = 0;
3. int c = a/b;
Segment 2:
4. float a = 1.0F;
5. float b = 0.0F;
6. float c = a/b;
Mutiple:
1) When executed, both segments will cause an exception to be thrown.
2) When executed, neither segment will cause an exception to be thrown.
3) Only Segment 1 will throw an exception.
4) Only Segment 2 will throw an exception.
Question 92
===========================================================
Which of the following classes override the equals() method.
Mutiple:
1) String
2) Integer
3) Double
4) Date
5) File
Question 93
===========================================================
Which of the following is the default layout manager for a panel.
Mutiple:
1) BorderLayout
2) FlowLayout
3) GridBagLayout
4) GridLayout
5) None of the above.
Question 94
===========================================================
True or False.
The StringBuffer class inherits from the String class.
Only One:
1) True
2) False
Question 95
===========================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -