📄 mockcert07.txt
字号:
Which of the following is/are true?
Mutiple:
1) A static method may be overridden by a static method.
2) A static method may be overridden by a non-static method.
3) A non-static method may be overridden by a static method.
4) A non-static method may be overridden by a final non-static method.
Question 41
===========================================================
The code below creates a button and a scrollbar, and adds them to a frame.
1. Frame frame = new Frame();
2. frame.setSize(450, 450);
3. Panel pan1 = new Panel();
4. pan1.setLayout(new GridLayout(2, 1));
5. Panel pan2 = new Panel();
6. Button b = new Button("B");
7. pan2.add(b);
8. pan1.add(pan2);
9. Scrollbar bar =
10. new Scrollbar(Scrollbar.HORIZONTAL);
11. pan1.add(bar);
12. frame.add(pan1, BorderLayout.NORTH);
13. frame.setVisible(true);
What is the button's height?
Only One:
1) The button's preferred height.
2) Something other than the button's preferred height.
Question 42
===========================================================
What does the following code print out?
1. byte b1 = -5;
2. int i = 0xff;
3. byte b2 = (byte)(b1 ^ i);
4. b2++;
5. System.out.println(b2);
Only One:
1) 4
2) -4
3) 5
4) -5
5) 6
Question 43
===========================================================
What method/methods of the KeyEvent class provide X and Y information about the event?
Mutiple:
1) There are no methods that provide this information.
2) int getX() and int getY()
3) Point getXY()
4) void getXY(Point p)
Question 44
===========================================================
Which of the following statements are true?
Mutiple:
1) After a blocked thread becomes unblocked, it must enter the Ready state before it can run.
2) After a sleeping thread wakes up, it must enter the Ready state before it can run.
3) After a waiting thread gets notified, it must enter the Ready state before it can run.
4) After a waiting thread gets notified, it must acquire the lock of the object for which it was waiting, before it can run.
Question 45
===========================================================
Does the following line of code compile?
byte b = 5;
Only One:
1) Yes
2) No
Question 46
===========================================================
What one statement is true about the following code fragment?
1. byte b1 = 32;
2. byte b2 = 3;
3. int i = 5 << (b1 + b2);
Only One:
1) The code generates a compiler error at line 3.
2) The code throws an exception at line 3.
3) After line 3 executes, the value of i is 0.
4) After line 3 executes, the value of i is 5.
5) After line 3 executes, the value of i is 40.
Question 47
===========================================================
Consider the following class definition:
class Parent {
void abcde(int i) throws IOException {
if (i > 10) throw new IOException();
}
}
Which of the following methods would be allowed in a subclass of Parent? Note: EOFException is a subclass of IOException.
Mutiple:
1) void abcde(byte i)
2) void abcde(byte i) throws Exception
3) float abcde(byte i) throws EOFException
4) void abcde(byte i) throws EOFException, IOException
5) static void abcde(int j) throws IOException
Question 48
===========================================================
What happens when you try to compile and run the following application? (Assume java.awt.Button is imported.)
1. class Z extends java.awt.Label {
2. private static double d;
3.
4. public static void main(String[] args) {
5. Inner inny = new Inner();
6. }
7.
8. class Inner extends Button implements Runnable {
9. Inner() { d = Math.PI; }
10. public void run() { }
11. }
12. }
Only One:
1) Compiler error at line 5.
2) Compiler error at line 8.
3) Compiler error at line 9.
4) he code compiles, but throws an exception at runtime.
5) The code compiles, and runs without throwing any exceptions.
Question 49
===========================================================
Consider the following class definition:
class Parent {
void abcde(int i) throws IOException {
if (i > 10) throw new IOException();
}
}
Which of the following methods would be allowed in a subclass of Parent? Note: EOFException is a subclass of IOException.
Mutiple:
1) void abcde(int i)
2) void abcde(int i) throws Exception
3) void abcde(int j) throws IOException
4) void abcde(int i) throws EOFException
5) void abcde(int j) throws IOException, EOFException
Question 50
===========================================================
What happens when you attempt to compile and execute the following application?
1. class Duck {
2. private int i;
3.
4. private void printOtherDucksI(Duck otherDuck) {
5. System.out.println("Other = " + otherDuck.i);
6. }
7.
8. public static void main(String[] args) {
9. Duck d1 = new Duck();
10. Duck d2 = new Duck();
11. d1.printOtherDucksI(d2);
12. }
13. }
Only One:
1) Compiler error at line 5.
2) Compiler error at line 11.
3) Exception thrown at line 5.
4) The application prints out: "Other = 0"
Question 51
===========================================================
Consider a String that is constructed by calling
String s = new String("AA\tBB\n");
Which of the calls listed here modify the string?
Only One:
1) s.trim();
2) s.toUpperCase();
3) s.toLowerCase();
4) s.substring(2);
5) None of the above
Question 52
===========================================================
What is the value of Math.floor(-Math.PI) ?
Only One:
1) 3
2) 4
3) -3
4) -4
Question 53
===========================================================
What does the following code print out?
1. class Cases {
2. public static void main(String[] args) {
3. String s = "abcde";
4. s.toUpperCase();
5. System.out.println(s);
6. }
7. }
Only One:
1) abcde
2) ABCDE
Question 54
===========================================================
What happens when you attempt to compile and execute the following code?
1. class A {
2. public static void main(String[] args) {
3. Integer i = new Integer(5);
4. i.setIntValue(i.intValue()+1);
5. System.out.println("i = " + i);
6. }
7. }
Only One:
1) Compiler error.
2) The code prints out "i = 5".
3) The code prints out "i = 6".
Question 55
===========================================================
What is the value of the following expression?
Math.floor(Math.min(-4.1, -4.8));
Only One:
1) -4 (an int)
2) -4.0 (a double)
3) -5 (an int)
4) -5.0 (a double)
Question 56
===========================================================
Which of the following statements is true?
Only One:
1) The trim() method removes leading and trailing whitespace from a string.
2) The trim() method removes all whitespace from a string.
Question 57
===========================================================
What is Math.min(Math.floor(-1.5), Math.ceil(-1.5)) ?
Only One:
1) -1 (an int)
2) -1.0 (a double)
3) -2 (an int)
4) -2.0 (a double)
Question 58
===========================================================
True or false: A list may not contain more than one reference to any one object.
Only One:
1) True
2) False
Question 59
===========================================================
What does the following application print out? (The size() method on line 15 returns the number of elements in the collection.)
1. import java.util.*;
2.
3. class Z {
4. public static void main(String[] args) {
5. StringBuffer sb1 = new StringBuffer("abcde");
6. StringBuffer sb2 = new StringBuffer("abcde");
7. sb2.reverse();
8. StringBuffer sb3 = new StringBuffer("wxyz");
9. Set set = new HashSet();
10. set.add(sb1);
11. set.add(sb1);
12. set.add(sb2);
13. set.add(sb2);
14. set.add(sb3);
15. System.out.println(set.size());
16. }
17. }
Mutiple:
1) "3"
2) "5"
Question 60
===========================================================
What does the weightx field of a GridBagConstraints control?
Only One:
1) How a component becomes wider when its container resizes.
2) How a column becomes wider when its container resizes.
3) How a component becomes taller when its container resizes.
4) How a row becomes taller when its container resizes.
Question 61
===========================================================
How many rows are in a container whose layout manager is constructed with the following code?
new GridLayout(3, 12);
Only One:
1) 3
2) 12
Question 62
===========================================================
Which of the following layout managers sometimes or always deliberately honor(s) a component's preferred width when a user resizes the container? Choose all correct options.
Mutiple:
1) Flow
2) Grid
3) Border
4) GridBag
Question 63
===========================================================
What is the result of attempting to compile and execute the following application?
1. public class X {
2. int[] intarr;
3.
4. public static void main(String[] args) { new X(); }
5.
6. X() {
7. int s = 100;
8. intarr = new int[s];
9. System.out.println("value = " + intarr[s-1]);
10. System.out.println("value = " + intarr[s]);
11. }
12. }
Only One:
1) Compiler error on line 8.
2) Compiler error on line 9.
3) Compiler error on line 10.
4) The code compiles, but throws an exception at line 9.
5) The code compiles, but throws an exception at line 10.
Question 64
===========================================================
Which of these statements is/are true about the following code? Choose all correct options.
1. public class Can {
2. public static void main(String[] args) {
3. Can theCan = new Can();
4. theCan = null;
5. System.gc();
6. System.out.println("On line 6 now.");
7. }
8. }
Mutiple:
1) After line 4 executes, the instance of Can is garbage collected.
2) After line 5 executes, the instance of Can is garbage collected.
3) None of the above.
Question 65
===========================================================
Which of the following statements is/are true? Choose all correct options.
Mutiple:
1) The most significant bit of a boolean is the sign bit.
2) The most significant bit of a byte is the sign bit.
3) The most significant bit of a char is the sign bit.
4) The most significant bit of a long is the sign bit.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -