⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mockcert07.txt

📁 一道JAVA方面的试题 很不错的 我很喜欢
💻 TXT
📖 第 1 页 / 共 5 页
字号:

Question 66
===========================================================
Which of the following is/are legal Java identifiers? Choose all correct options.

Mutiple: 
1) $1
2) Goto
3) 1$
4) BYTE
5) break


Question 67
===========================================================
How many boolean literal values are there?

Only One: 
1) 0
2) 1
3) 2
4) 3
5) 4


Question 68
===========================================================
Which of the following is/are legal assignments of a literal value to a String variable? Choose all correct options.

Mutiple: 
1) String s = "\"";
2) String s = \"abcde\";
3) String s = "\u3456\ufde6\u0\u1234";
4) String s = "\"\"\"\\\\";


Question 69
===========================================================
Consider the following line of code:
boolean[] b = new boolean[25];
After this line executes, which of the following statements is/are true? Choose all correct options.

Mutiple: 
1) b[4] is undefined.
2) b[25] does not exist.
3) b[25] is false.
4) b[24] is false.
5) b.size = 25.


Question 70
===========================================================
A final method inside an anonymous inner class declares and constructs an array of int. Are the array elements automatically initialized?

Only One: 
1) Yes
2) No


Question 71
===========================================================
In the following code fragment, what is the value of k after line 3 executes? 
1. int i = -1;
2. int j = i >>> 31;
3. int k = j & 51;

Only One: 
1) 1
2) 0
3) -1
4) A very large negative number
5) A very large positive number


Question 72
===========================================================
In the following code, does line 7 compile? 
1.  class Outside {
2.    private float i;
3.    
4.    void amethod(float j) {
5.      class Inside {
6.        void innerFoo() {
7.          float k = i + j;
8.          System.out.println("k = " + k);
9.        }
10.     }
11.   }
12. }

Only One: 
1) Yes
2) No


Question 73
===========================================================
Which of the following statements is/are true? Choose all correct options.

Mutiple: 
1) An anonymous inner class may declare that it extends any non-final superclass.
2) An anonymous inner class may declare that it implements any one interface.
3) An anonymous inner class may declare that it implements multiple interfaces.
4) An anonymous inner class may declare that it extends any non-final superclass, and also declare that it implements any one interface.
5) An anonymous inner class may declare that it extends any non-final superclass, and also declare that it implements multiple interfaces.


Question 74
===========================================================
Which of the following statements is/are true? Choose all correct options.

Mutiple: 
1) At the moment a thread calls an object's wait() method, the thread must own that object's lock.
2) At the moment a thread calls an object's wait() method, the thread loses that object's lock.
3) At the moment a waiting thread is notified, it is given the lock of the object for which it was waiting.
4) At any moment, a thread may not be waiting for the lock of more than one object.


Question 75
===========================================================
Does the following code compile? 
1. class Parent {
2.   int i;
3.   private synchronized(System.out) void zzz() {
4.     synchronized(System.out) { i = 5; }
5.   }
6. }

Only One: 
1) Yes
2) No


Question 76
===========================================================
What happens when you try to compile and run the following application? Choose all correct options. 
 1. class Z {
 2.   public static void main(String[] args) {
 3.     new Z();
 4.   }
 5.
 6.   Z() {
 7.     Z alias1 = this;
 8.     Z alias2 = this;
 9.     synchronized(alias1) {
10.       try {
11.         alias2.wait();
12.         System.out.println("DONE WAITING");
13.       }
14.       catch (InterruptedException e) {
15.         System.out.println("INTERRUPTED");
16.       }
17.       catch (Exception e) {
18.         System.out.println("OTHER EXCEPTION");
19.       }
20.       finally {
21.         System.out.println("FINALLY");
22.       }
23.     }
24.     System.out.println("ALL DONE");
25.   }
26. }

Mutiple: 
1) Compiler error.
2) The application compiles but doesn't print anything.
3) The application prints "DONE WAITING".
4) The application prints "INTERRUPTED".
5) The application prints "OTHER EXCEPTION".


Question 77
===========================================================
Which of the following statements is/are true? Choose all correct options.

Mutiple: 
1) If two threads with different priorities are ready to run, the thread with the higher priority will be run first.
2) If two threads with equal priorities are ready to run, the thread that became ready first will be run first.
3) Neither of the above is true.


Question 78
===========================================================
True or false: All methods in all event listener interfaces in the java.awt.event package are public.

Only One: 
1) True
2) False


Question 79
===========================================================
Assume that the class Adj implements the AdjustmentListener interface. The following code fragment constructs a Scrollbar and gives it some instances of Adj to be its adjustment listeners. When the scrollbar is adjusted, which listener is the first one to receive the adjustmentValueChanged() method? 
Scrollbar s = new Scrollbar();
Adj a1 = new Adj();
Adj a2 = new Adj();
Adj a3 = new Adj();
s.addAdjustmentListener(a1);
s.addAdjustmentListener(a2);
s.addAdjustmentListener(a3);
a.removeAdjustmentListener(a1);
s.removeAdjustmentListener(a2);
s.addAdjustmentListener(a2);
s.addAdjustmentListener(a1);

Only One: 
1) a1
2) a2
3) a3
4) There is no guarantee as to which listener will be first.


Question 80
===========================================================
What happens when you try to compile and run the following application? 
 1. import java.io.*;
 2. class C {
 3.   public static void main(String[] args) {
 4.     try {
 5.       RandomAccessFile raf = 
 6.         new RandomAccessFile("f", "rw");
 7.       DataOutputStream dos = new DataOutputStream(raf);
 8.       dos.writeFloat(-5.6f);
 9.       dos.close();
10.       DataInputStream dis = new DataInputStream(raf);
11.       float f = dis.readFloat();
12.       dis.close();
13.       raf.close();
14.       System.out.println(f);
15.     }
16.     catch (IOException e) { System.out.println("Oops"); }
17.   }
18. }

Only One: 
1) Compiler error.
2) The program prints out "-5.6".
3) The program prints out a numeric value other than -5.6.
4) The program prints out "Oops".


Question 81
===========================================================
True or false : An instance of the java.io.Directory class can represent a file or a directory.

Only One: 
1) True
2) False


Question 82
===========================================================
The following lines of code all involve assignment and casting. Which line(s) would fail to compile if the cast were omitted? Choose all correct options.

Mutiple: 
1) char c = 'c'; int i = (int)c;
2) double d = 12.34; long lon = (long)d;
3) float f = 12.34f; long lon = (long)f;
4) byte b = (byte)3;


Question 83
===========================================================
Which of the following statements is/are true? Choose all correct options.

Mutiple: 
1) The double type is wider than the int type.
2) The long type is wider than the char type.
3) The char type is wider than the short type.
4) The short type is wider than the char type.


Question 84
===========================================================
In the following code, what are the legal types for the variable vari, which is declared and constructed on line 11? Just think about the type of vari; assume the declaration and construction on line 11 are legal. Choose all correct options. 
 1. class Fruit {}
 2. class Apple extends Fruit { }
 3. interface Squeeze {}
 4. class Citrus extends Fruit implements Squeeze {}
 5. class Orange extends Citrus {}
 6.
 7. class NavelOrange extends Orange {
 8.   static void foo(Citrus c) { }
 9.
10.   public static void main(String[] args) {
11.     ??? vari = ???;
12.     foo(vari);
13.   }
14. }

Mutiple: 
1) Apple
2) Squeeze
3) Citrus
4) Orange
5) NavelOrange


Question 85
===========================================================
What does the following code print out? 
1. try {
2.   double d = -12.34 % -5;
3.   System.out.println("d = " + d);
4. }
5. catch (Exception e) { System.out.println("TROUBLE"); }

Only One: 
1) d = 2
2) d = -2
3) d = 2.34
4) d = -2.34
5) TROUBLE


Question 86
===========================================================
You are given the class file for a class called Secret. However, you do not have the source code or any information about the internals of the Secret class. You do know that the class has a protected int variable called i. What does the following application print out? 
 1. class Mine extends Secret {
 2.   public static void main(String[] args) {
 3.      Mine m1 = new Mine(); m1.i = 5;
 4.      Mine m2 = new Mine(); m1.i = 5;
 5.      if (m1.equals(m2))
 6.        System.out.println("YES");
 7.      else
 8.        System.out.println("NO");
 9.   }
10. }

Only One: 
1) YES
2) NO
3) It is impossible to know.


Question 87
===========================================================
What happens when you attempt to compile the following code? 
1. class A           {  static void foo() {};         }
2. class B extends A {  public static void foo() {};  }

Only One: 
1) Compiler error at line 1.
2) Compiler error at line 2.
3) No compiler error.


Question 88
===========================================================
Which access is more restrictive: protected or "default" (where "default" is the access when you don't explicitly specify private, protected, or public)?

Only One: 
1) protected is more restrictive.
2) "default" is more restrictive.


Question 89
===========================================================
You create a class called A with a final static variable called z. Is it possible to have three instances of A, each of which has a different value for z?

Only One: 
1) Yes
2) No


Question 90
===========================================================
True or false: An abstract class that does not contain any non-abstract methods is the same as an interface.

Only One: 
1) True
2) False


Question 91
===========================================================
Given the following code, which access modifiers can legally be placed before aMethod() on line 6? Choose all correct options. 
1. class Thing {
2.   void aMethod() { }
3. }
4.
5. class SubThing extends Thing {
6.   void aMethod() { }
7. }

Mutiple: 
1) public
2) protected
3) private

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -