现在的位置: 首页 > 综合 > 正文

(转)老紫竹的小测试

2012年12月29日 ⁄ 综合 ⁄ 共 3608字 ⁄ 字号 评论关闭

测试1.1

下面哪些方法是正确的定义,用来从命令行启动程序
  A. static public void main(String [] args) {} 
 
  B. public static int main(String [] args) {} 
 
  C. public static void main(String args []) {} 
 
  D. public static void main(String [] argh) {} 

 

测试1.2

如下数据是一个地区的昆虫数量数据
A 蜘蛛:2^8
B 蜜蜂:2^17
C 蚂蚁:2^31
D 蚊子:2^56
上述的^代表次幂的意思
哪些昆虫的数量可以用int数据类型来保存

测试1.3

下面代码的输出为哪一个?
class Test {   
  
public int t = 4;   
  
public static void main(String[] args) {   
    
new Test().NumberPlay();   
  }   
  
public void NumberPlay() {   
     
int t = 2;   
    t 
= t + 5;   
    
this.t = this.t - 2;   
    t 
= t - this.t;   
    System.out.print(t 
+ " ");   
    System.out.println(
this.t);   
  }   

A. 2 5  
  B. -9 0  
  C. 0 -9  
  D. 5 2  
  E. 7 2  
  F. 2 7 

测试1.4

下面那些类的声明是正确的
  A. private class A {} 
 
  B. class B {} 
 
  C. public class C {} 
 
  D. final class Class {} 
 
  E. abstract class E; 
 
  F. final abstract class F {} 

测试1.5

1. strictfp class Main { 
2.   public Main() { 
3.   } 
4.   public void Main() { 
5.   } 
6.   strictfp public void Main(double x) { 
7.   } 
8. } 

这些代码下面哪些描述是正确的?
  A. The code will compile and run fine.  
  B. The code won't compile because of line 1.  
  C. The code won't compile because of line 2.  
  D. The code won't compile because of line 4.  
  E. The code won't compile because of line 6. 

测试1.6

假设你已经书写了一个java文件的源代码,里面没有public的类,现在你想保存并编译它,下面哪些做法可以实现

  A. 保存到 MyClass.jav 文件里面,并且使用 javac MyClass.jav 进行编译 
 
  B. 保存到 1999Work.java  文件里面,并且使用  javac 1999Work.java.进行编译
 
  C. 保存到 MyClass.java  文件里面,并且使用  javac MyClass 进行编译
 
  D. 保存到 MyClass.java  文件里面,并且使用  javac MyClass.java 进行编译

测试1.7

下面哪些方法可以增加到一个正常的类里面?只插入一个,不是一起插入。
  A. public void main(String [] args) {} 
 
  B. public int main(String [] args) {return 2;} 
 
  C. public static void main() {} 
 
  D. void public static main(String [] args) {} 

测试1.8

看下面的 FirstClass.java
1. import java.*; 

2. public class FirstClass {} 

3. public interface Second {} 

4. abstract class SecondClass {} 

有哪些编译错误?
  A. import 的 java 包找不到 
  B. public class FirstClass 必须定义在文件名为 "FirstClass.java" 的文件中 
  C. public interface Second 必须定义在文件名为 "Second.java" 的文件中 
  D. Class SecondClass 不能声明为 abstract. 
  E. 没有错误,文件编译正常

测试1.9

下面哪个接口的声明是正确的?
  A. public interface A {int a();} 
 
  B. public interface B implements A {} 
 
  C. interface C {int a;} 
 
  D. private interface D {} 
 
  E. abstract interface E {} 

测试1.10

如下代码
1. class DataServer extends Server{ 
2. public String serverName; 
3. public DataServer () { 
4. serverName = "Customer Service"; 
5. super(serverName); 
6. } 
7. } 

下面哪些描述是正确的?
  A. 代码编译并运行正常 
  B. 代码编译正常,但执行使发生错误 
  C. 代码无法编译,第2行错误 
  D. 代码无法编译,第5行错误 

测试1.11

下面哪些代码放到类里面可以正常编译
  A. public static final synchronized getPrice() {} 
 
  B. public abstract int getPrice(); 
 
  C. public static final int getPrice() {} 
 
  D. public final static int getPrice(int unit) {return unit;} 
 
  E. protected volatile int getPrice() {}  
  

测试1.12

下面2个类
1. public class Century implements Runnable { 
2.   public void run () { 
3.     for (int year = 1900;year < 2000;year++) { 
4.       System.out.println(year); 
5.       try {Thread.sleep(1000); 
6.       } catch(InterruptedException e) {} 
7.     } 
8.     System.out.println("Happy new millenium!"); 
9.   } 
10. } 

11. class CountUp { 
12.   public static void main (String [] args) { 
13.   Century ourCentury = new Century(); 
14. 
15.   } 
16. } 

你想在第二个类里面启动第一个类的线程,在第14行应该怎样做?
  A. Thread t = new Thread(this);
     t.start(); 
 
  B. Thread t = new Thread(ourCentury);
     ourCentury.start(); 
 
  C. Thread t = new Thread(this);
     t.start(ourCentury); 
 
  D. Thread t = new Thread(this);
     ourCentury.run(); 
 
  E. Thread t = new Thread(ourCentury);
     t.start(); 

  F. protected int static getPrice(int unit) {} 

抱歉!评论已关闭.