100分 发表于 2020-8-7 10:38:14

北理工20年秋JAVA题库三

一 判断题1JAVA中一个类只能实现一个接口,但可以继承多个类。         2JAVA程序中一个汉字和一个英文字母占的字节数相同         3一个抽象类中只能包含抽象方法。                            4最终类(final)不能派生子类,最终方法不能被覆盖。             5Java源文件中的类名必须要与文件名相同。   二、选择题
1.下面哪一个表示十六进制整数?
(A)0XA6      
(B) 1234L      
(C) -840      
(D) 0144
题型:单选题
知识点:数据表示
难度:22.下列有关一个Java文件的叙述,正确的是?
可以有2个以上package语句
可以有2个以上import语句
可以有2个以上public类
(D)只能有1个类定义
题型:单选题
知识点:基础综合
难度:23. 下列语句会产生编译错误的是?
(A)float F = 1024.0F;
(B)double D = 1024.0;
(C)byte B = 1024;
(D)char C = 1024;
题型:单选题
知识点:基础综合
难度:2
4.按照Java的标识符命名规则,下列哪个标识符作为类的名字合适?
(A)Helloworld          
(B)HelloWorld
(C)helloworld             
(D)helloWorld
题型:单选题
知识点:命名规范
难度:25.以下选项中哪一个不是Java的特点:
(A)自动垃圾回收          
(B)跨平台
(C)面向对象                       
(D)多重继承
题型:单选题
知识点:JAVA特性
难度:2三、简答题(每题4分,共20分)1.写一个HelloWorld的程序
题型:简答题
知识点:JAVA基础
难度:12.试解释Java关键字final与 finally的意义及用法。
题型:简答题
知识点:JAVA关键字
难度:1
3.举例说明java异常处理的一般程序结构?
题型:简答题
知识点:异常处理
难度:2进程和线程的区别是什么?
题型:简答题
知识点:进程与线程
难度:2
   
四、分析题:
下列程序中由输出的显示结果是什么?程序1
public class abc {       public static void main(String args[])       {       Strings1 = "Hello!";       Strings2 = new String("World!");       System.out.println(s1.concat(s2));       } }
运行结果:

答案:Hello!World!
题型:程序分析题
知识点:JAVA综合
难度:1程序2
public class Test{
        static int x = 5;
public static void methodA()
    {
      int x = 2;
++x;
System.out.println("x in methodA() =" + x);
    }
    public static void methodB()
    {
x *= 5;
System.out.println("x in methodB() =" + x);
    }
public static void main(String args[])        {
          int x = 5;
    methodA();   
      methodB();
             System.out.println("x in main() =" + x);
        }
}
运行结果:
题型:程序分析题
知识点:JAVA综合
难度:2
程序3:
class JavaTest {
    public static void main(String args[]){
      int numbers[]=new int;
      try{
    for(int i=1;i<=10;i++)
      numbers=i;
      }
      catch(ArrayIndexOutOfBoundsException e) {
            System.out.println("下标越界");       
      }
      finally        {
            System.out.println("退出函数。");               
      }
      System.out.println("退出main()");
    }
}               
运行结果:
题型:程序分析题
知识点:JAVA综合
难度:2
程序4:
class Father {     voidprintMe()     {       System.out.println("father");     } } classSonextends Father {     voidprintMe()     {       System.out.println("son");     }     voidprintAll()     {       super.printMe();       this.printMe();       printMe();     } } public classTest {     public static void main(Stringargs[ ])     {       Sonson = newSon( );       son.printAll( );     } }
运行结果:

题型:程序分析题
知识点:JAVA综合
难度:2
五、判错题:(每题5分,共20分)
下列程序是否有错?如果有错试标出所有错误位置并指出是何种错误。(假定每个程序最多一个错误)程序5
class Father{
        void methodA (){
                System.out.println("methodA");
        }
}
class Mother{
        void methodB(){
                System.out.println("methodB");
        }
}
class Son extends Father,Mother
void methodC(){
    System.out.println("methodC");
}
}
错误分析:
题型:程序找错题
知识点:JAVA综合
难度:2程序6.
public class Something {
   public intaddOne(final int x) {
       return ++x;
   }
}       
错误分析:
答案:int x被修饰成final,意味着x不能在addOne method中被修改
题型:程序找错题
知识点:JAVA综合
难度:2程序7
class JavaTest {
public static void main(String args[]) {
        Integer b[] = new Integer[ 100 ];
        int i;
        for(i=0;i<100;i++) {
             System.out.println(b.intValue()+1);
        }
}
}
错误分析:
答案:数组里的对象没有初始化
题型:程序找错题
知识点:JAVA综合
难度:2程序8
abstract class Father{
   public void printMsg(String msg)        {
    System.out.println(“father:”+msg);
}
public abstract void printMsg2();
}
public class Child extends Father{
        public void printMsg(String msg)        {
      System.out.println(“child:”+msg);
        }
        public static void main(String[] args) {
      Child ch = new Child();
      Father fa = (Father)ch;
      fa.PrintMsg();
        }
}
错误分析:
题型:程序找错题
知识点:JAVA综合
难度:2六、编程题(每题10分,共20分)
将程序源代码写在试卷所附的白纸上,注明组别与题号。
1.排序:
        整数数组a[]中有若干个整数,请写程序将数组中的整数从小到大排列。
   void sortArray(int a[],int len)      //a[]为待排序的数组,len为数组元素个数
题型:编程题
知识点:JAVA综合
难度:2 北理工作业 无忧答案网整理
页: [1]
查看完整版本: 北理工20年秋JAVA题库三