选择题
关于接口,找出下列错误的叙述:
A.接口中的数据(成员变量)必须被赋初值,且程序运行过程中不可更改。
B.可以直接由接口来创建对象。
C.接口中的方法都必须全部声明为抽象方法。
D.类与接口类似的是:接口中也含有数据(成员变量)和方法。

找出正确表述Java语言面向对象特性的选项:
Java程序设计语言将类作为部分特性和行为事务的抽象。
Java程序设计语言提供了丰富的API文档。
Java程序设计语言的运行与平台无关。
Java程序设计语言具有封装、继承和多态的特性。

3、找出下列代码的输出结果。
class TestException{
  public static void main(String[] args){
    try{
      oneMethod( );
    }
    catch(Exception e){ 
      System.out.println("there is an exception"); 
    }
  }
  static void oneMethod( ){
    try{
      anotherMethod( );
      System.out.println("normal");
    }
    catch(ArithmeticException e){
      System.out.println("there is an arithmeticexception");
    } 
    finally{
      System.out.println("in finally");
    }
    System.out.println("outside try block");
  }
  static void anotherMethod( ){
    throw new NullPointerException( );
  }
}

A.程序无法处理该异常,异常由系统处理
B. in finally there is an exception
C. there is an arithmeticexception in finally there is an exception
D. normal outside try block
4.找出语法表述正确的程序段:
A. String mm = "Java Programme "; String nn = mm.toUpperCase;
B. String mm = " Java Programme "; String nn = mm - " Programme ";
C. String mm = "Java Programme "; String nn; nn = mm[8] + "Java";
D. String mm = "Java Programme "; String nn = " Learning "; String ss = nn + mm;

5、有关多态性的正确说法是:
A. 在一个类中不能有同名的方法存在。
B. 子类中可以有和父类中同名且参数相同的方法。
C. 多态性就是方法的名字可以相同,但返回的类型必须不同。
D. 子类中不能有和父类中同名的方法。

6、选出将十进制数256的十六进制表示形式赋值给decbin变量的正确表达式。
A. long decbin =040L
B. long decbin =0400L
C. long decbin =0x256L
D. long decbin =0x100L

7、找出返回值类型是字符型的方法:
A. length()
B. charAt(int x)
C. substring(int x)
D. toLowerCase()

8、在Applet的运行过程中,下列什么方法只能执行一次?
A. init()
B. stop()
C. start()
D. paint()

9、#1  public abstract class test{
    #2    public abstract void methodA();
    #3    public abstract void methodB(){
    #4       System.out.println("Hello!");
    #5    }
    #6  }
从下面选出一个正确的修改方案使代码通过编译。
A. 删除methodB声明部分的abstract修饰符。
B. 删除test声明部分的abstract修饰符。
C. 对methodA添加方法体。
D. 删除methodA声明部分的abstract修饰符。

10、中文语句“如果x和y都不等于z,或者x等于y,则输出'x'。”可以写成下列哪一个Java语句?
A. if (!(x == z) && !(y == z) && x == y) System.out.println('x');
B. if (x && y != z || x == y) System.out.println('x');
C. if (x != z|| y != z && x == y) System.out.println('x');
D. if (!(x == z || y == z) || x == y) System.out.println('x');

11、选出下列代码执行后的输出结果。
class Person{
     public int age;
     public Person(){
          age=20;
     }
     public void show(){
          System.out.println("Person's age is "+age);
     }
}
class Student extends Person{
     public int age;
     public void show(){
        super.show();                
        age=super.age+age;    
        System.out.println("Student's age is "+age);
     }
}
class Test{
     public static void main(String args[]){
        int initAge=10;
        Student tt=new Student();
        tt.age=initAge;
        tt.show();
     }
}
A. Person's age is 0 Student's age is 10
B. Person's age is 0 Student's age is 0
C. Person's age is 20 Student's age is 20
D. Person's age is 20 Student's age is 30

12、下面哪个选项不是Java程序设计语言的面向对象要素?
A. 类与对象
B. 特性与行为
C. 安全模型
D. 变量与方法

13、指出下列哪个方法与方法public void change(int x, int y){}为不合理的重载方法。
A. public void change(int x){}
B. public int change(int x, int y){}
C. public float change(float x, float y){}
D. public long change(long x, long y){}

14、哪个选项不可以作为Java图形用户界面上的容器?
A. TextField
B. Dialog
C. Frame
D. Panel

第二题   程序填空
UseComputer类创建两个Computer类的对象并调用相应的方法。Computer类用于定义计算机的硬件性能:CPU速度(speed)、内存大小(memory)、硬盘容量(diskSpace)。
    当程序正确完成后,产生的输出如下所示:
    
    C:\>java UseComputer
    2.0GHz 1024MB内存 128GB硬盘
    3.2GHz 2048MB内存 256GB硬盘
    3.2GHz 2048MB内存 128GB硬盘
    3.4GHz 3072MB内存 256GB硬盘
    较好的是:3.4GHz 3072MB内存 256GB硬盘
    
    【程序】
public class UseComputer{
   public static void main(String []args){
      Computer computer1 = new Computer(2.0, 1024, 128);
      Computer computer2 = new Computer(3.2, 2048, 256);
      System.out.println(computer1);
      System.out.println(computer2);
      computer1.upGradeMemory(1024);
      computer1.replaceCPU(3.2);
      computer2.upGradeMemory(1024);
      computer2.replaceCPU(3.4);
      System.out.println(computer1);
      System.out.println(computer2);
    if (computer1.compare(computer2))
         System.out.println("较好的是:"+computer1);
      else
         System.out.println("较好的是:"+computer2);
   }
}

class Computer {
        (1)____        
   private int memory;
   private int diskSpace;
   public Computer(double initSpeed, int initMemory, int initDiskSpace) {
      speed = initSpeed;
      memory = initMemory;
      diskSpace = initDiskSpace;
   }
   public String toString() {
             (2)_____                    
   }
   public void upGradeMemory(int extraMemory) {
             (3)_____          
   }
   public void replaceCPU(double newSpeed) {
             (4)_____               
   }
   public boolean compare(Computer other){
      return      (5)       ;
   }
     }



谢谢了,帮个忙,偶初来乍到!