?? mockcert06.txt
字號:
Question 1
===========================================================
True or false: A signed data type has an equal number of non-zero positive and negative values available.
Only One:
1) True
2) False
Question 2
===========================================================
Choose the valid identifiers.
Mutiple:
1) BigOlLongStringWithMeaninglessName
2) $int
3) bytes
4) $1
5) finalist
Question 3
===========================================================
Which of the following signatures are valid for the main() method entry point of an application?
Mutiple:
1) public static void main()
2) public static void main(String arg[])
3) public void main(String [] arg)
4) public static void main(String[] args)
5) public static int main(String [] arg)
Question 4
===========================================================
If all three top-level elements occur in a source file, they must appear in which order?
Only One:
1) Imports, package declaration, classes.
2) Classes, imports, package declarations.
3) Package declaration must come first; order for imports and class definitions is not significant.
4) Package declaration, imports, classes.
5) Imports must come first; order for package declaration and class definitions is not significant.
Question 5
===========================================================
Consider the following line of code:
int[] x = new int[25];
After execution, which statement or statements are true?
Mutiple:
1) x[24] is 0.
2) x[24] is undefined.
3) x[25] is 0.
4) x[0] is null.
5) x.length is 25.
Question 6
===========================================================
Consider the following application:
1. class Q6 {
2. public static void main(String args[]) {
3. Holder h = new Holder();
4. h.held = 100;
5. h.bump(h);
6. System.out.println(h.held);
7. }
8. }
9.
10. class Holder {
11. public int held;
12. public void bump(Holder theHolder) {
13. theHolder.held++;
14. }
15. }
What value is printed out at line 6?
Only One:
1) 0
2) 1
3) 100
4) 101
Question 7
===========================================================
Consider the following application:
1. class Q7 {
2. public static void main(String args[]) {
3. double d = 12.3;
4. Decrementer dec = new Decrementer();
5. dec.decrement(d);
6. System.out.println(d);
7. }
8. }
9.
10. class Decrementer {
11. public void decrement(double decMe) {
12. decMe = decMe - 1.0;
13, }
14. }
What value is printed out at line 6?
Only One:
1) 0.0
2) -1.0
3) 12.3
4) 11.3
Question 8
===========================================================
How can you force garbage collection of an object?
Only One:
1) Garbage collection cannot be forced.
2) Call System.gc().
3) Call System.gc(), passing in a reference to the object to be garbage-collected.
4) Call Runtime.gc().
5) Set all references to the object to new values (null, for example).
Question 9
===========================================================
What is the range of values that can be assigned to a variable of type short?
Only One:
1) It depends on the underlying hardware.
2) 0 through 2^16 - 1
3) 0 through 2^32 - 1
4) -2^15 through 2^15 - 1
5) -2^31 through 2^31 - 1
Question 10
===========================================================
What is the range of values that can be assigned to a variable of type byte?
Only One:
1) It depends on the underlying hardware.
2) 0 through 2^8 - 1
3) 0 through 2^16 - 1
4) 0 through 2^16 - 1
5) -2^15 through 2^15 - 1
Question 11
===========================================================
After execution of the code fragment below, what are the values of the variables x, a, and b?
1. int x, a = 6, b = 7;
2. x = a++ + b++;
Only One:
1) x = 15, a = 7, b = 8
2) x = 15, a = 6, b = 7
3) x = 13, a = 7, b = 8
4) x = 13, a = 6, b = 7
Question 12
===========================================================
Which of the following expressions are legal? (Choose one or more.)
Mutiple:
1) int x = 6; x = !x;
2) int x = 6; if (!(x > 3)) {}
3) int x = 6; x = ~x;
Question 13
===========================================================
Which of the following expressions results in a positive value in x? (Choose one.)
Only One:
1) int x = -1; x = x >>> 5;
2) int x = -1; x = x >>> 32;
3) byte x = -1; x = x >>> 5;
4) int x = -1; x = x >> 5;
Question 14
===========================================================
Which of the following expressions are legal? (Choose one or more.)
Mutiple:
1) String x = "Hello"; int y = 9; x += y;
2) String x = "Hello"; int y = 9; if (x == y) {}
3) String x = "Hello"; int y = 9; x = x + y;
4) String x = "Hello"; int y = 9; y = y + x;
5) String x = null;int y = (x != null) && (x.length() > 0) ? x.length() : 0;
Question 15
===========================================================
Which of the following code fragments would compile successfully and print "Equal" when run? (Choose one or more.)
Mutiple:
1) int x = 100; float y = 100.0F;
if (x == y){ System.out.println("Equal");}
2) int x = 100; Integer y = new Integer(100);
if (x == y) { System.out.println("Equal");}
3) Integer x = new Integer(100);
Integer y = new Integer(100);
if (x == y) { System.out.println("Equal");}
4) String x = new String("100");
String y = new String("100");
if (x == y) { System.out.println("Equal");}
5) String x = "100";
String y = "100";if (x == y) { System.out.println("Equal");}
Question 16
===========================================================
What results from running the following code?
1. public class Short {
2. public static void main(String args[]) {
3. StringBuffer s = new StringBuffer("Hello");
4. if ((s.length() > 5) &&
5. (s.append(" there").equals("False")))
6. ; // do nothing
7. System.out.println("value is " + s);
8. }
9. }
Only One:
1) The output: value is Hello
2) The output: value is Hello there
3) A compiler error at line 4 or 5
4) No output
5) A NullPointerException
Question 17
===========================================================
What results from running the following code?
1. public class Xor {
2. public static void main(String args[]) {
3. byte b = 10; // 00001010 binary
4. byte c = 15; // 00001111 binary
5. b = (byte)(b ^ c);
6. System.out.println("b contains " + b);
7. }
8. }
Only One:
1) The output: b contains 10
2) The output: b contains 5
3) The output: b contains 250
4) The output: b contains 245
Question 18
===========================================================
What results from attempting to compile and run the following code?
1. public class Conditional {
2. public static void main(String args[]) {
3. int x = 4;
4. System.out.println("value is " +
5. ((x > 4) ? 99.99 : 9));
6. }
7. }
Only One:
1) The output: value is 99.99
2) The output: value is 9
3) The output: value is 9.0
4) A compiler error at line 5
Question 19
===========================================================
What is the output of this code fragment?
1. int x = 3; int y = 10;
2. System.out.println(y % x);
Only One:
1) 0
2) 1
3) 2
4) 3
Question 20
===========================================================
What results from the following fragment of code?
1. int x = 1;
2. String [] names = { "Fred", "Jim", "Sheila" };
3. names[--x] += ".";
4. for (int i = 0; i < names.length; i++) {
5. System.out.println(names[i]);
6. }
Only One:
1) The output includes Fred. with a trailing period.
2) The output includes Jim. with a trailing period.
3) The output includes Sheila. with a trailing period.
4) None of the outputs show a trailing period.
5) An ArrayIndexOutOfBoundsException is thrown.
Question 21
===========================================================
Which of the following declarations are illegal? (Choose one or more.)
Mutiple:
1) default String s;
2) transient int i = 41;
3) public final static native int w();
4) abstract double d;
5) abstract final double hyperbolicCosine();
Question 22
===========================================================
Which one of the following statements is true?
Only One:
1) An abstract class may not have any final methods.
2) A final class may not have any abstract methods.
Question 23
===========================================================
What is the minimal modification that will make this code compile correctly?
1. final class Aaa
2. {
3. int xxx;
4. void yyy() { xxx = 1; }
5. }
6.
7.
8. class Bbb extends Aaa
9. {
10. final Aaa finalref = new Aaa();
11.
12. final void yyy()
13. {
14. System.out.println("In method yyy()");
15. finalref.xxx = 12345;
16. }
17. }
Only One:
1) On line 1, remove the final modifier.
2) On line 10, remove the final modifier.
3) Remove line 15.
4) On lines 1 and 10, remove the final modifier.
5) The code will compile as is. No modification is needed.
Question 24
===========================================================
Which one of the following statements is true?
Only One:
1) Transient methods may not be overridden.
2) Transient methods must be overridden.
3) Transient classes may not be serialized.
4) Transient variables must be static.
5) Transient variables are not serialized.
Question 25
===========================================================
Which one statement is true about this application?
1. class StaticStuff
2 {
3. static int x = 10;
4.
5. static { x += 5; }
6.
7. public static void main(String args[])
8. {
9. System.out.println("x = " + x);
10. }
11.
12. static { x /= 5; }
13. }
Only One:
1) Lines 5 and 12 will not compile, because the method names and return types are missing.
2) Line 12 will not compile, because you can only have one static initializer.
3) The code compiles, and execution produces the output x = 10.
4) The code compiles, and execution produces the output x = 15.
5) The code compiles, and execution produces the output x = 3.
Question 26
===========================================================
Which one statement is true about this code?
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -