JavaA卷

    技术2022-05-11  30

    考生承诺:我将严格的遵守考试纪律,并知道考试违纪、作弊的严重后果,并承担由此引发的一切后果。 课程名称:         考试时间             日学院:          专业:         班级:         姓名:          学号:          评    分   教师签字   一、填空题:(每小题1分,共10分) 1. Javac命令的作用___________________________。 2. 子类继承父类的使用关键字________________________。 3. 面向对象编程的主要特点__________________________。 4. Java语言采用_________________继承。 5. 字符串类对象按字典顺序进行字符串比较使用的方法_______________。 6. 网络操作中服务器端需要使用______________类创建服务器端对象。 7. 在字符串操作中用_________________方法求子串。 8. 将字符串:“12.45”常量赋予到双精度类型d使用方法________________。 9. 接口中的变量默认使用的数据类型___________________。 10. 定义抽象方法所使用的关键字:_______________________。 二、简答题:(每小题4分,共16分) 1. 接口与抽象类之间区别和各自特点。             2. 网络操作中客户端的主要操作过程。             3. 什么是对象上转型对象和对象上转型对象的主要特点。             4. 请列举字符串分析器中3种常用的方法与各自功能说明。           三、选择题:(每小题2分,共14分) 1. Javap命令的作用。 A.      编译源文件                 B.执行java字节码文件 C.小应用程序查看器            D.反编译java源文件查看其主要成员方法和构造方法 2. 下列说法中错误是: A. 在接口中可以包含成员变量与成员方法的定义. B. 在抽象类中可以包含成员变量与成员方法,但其必须只能有方法的声明。 C.      在接口中默认的方法类型为public abstract 类型。 D.     抽象类需要在子类被继承才有意义 3. 下列说法那些是正确的: A.同一包内若两个类构成继承关系,则子类可以使用父类中所有的访问权限。 B.不同包中的两个类构成继承关系,子类不需要引用父类所在的包即可直接使用。 C.不同包中的两个类构成继承关系,子类可以使用父类中default 所定义的方法。 D.在同一个包内的两个源文件不使用引用包就可了用另外一个源文件中所定义的类。   4. class  a {    int   i=9;     ①     static int j=10; ② System.out.print(i);     ③   Final int f=19; ④        public static void main(String[] args) ⑧        {         f=9; ⑤               int d=j + i; ⑥               System.out.println(d); ⑦        } } 下列语法正确无错误的为: A. ③ ⑤ ⑥ ⑦ B. ① ④ ⑥ ⑦  C. ⑤ ⑥ ⑦ ⑧  D ① ④ ⑦ ⑧ 5. java源文件temp.java中有如下代码: class  a {    int   i=9;           public static void main(String[] args)        {               System.out.println(i);        } } class t {    void t()   {} } interface b {    void disp();    int disp() {} } class m {    class n implements b    {} } 下列说法那些是正确的( ): A.      程序运行需使用java a.class 命令进行运行 B.      程序中有一处错误 C.      在执行java编译时候需要使用javac TeMp.java 进行编译 D.     以上说法都错误 6.上述程序若能正确编译并运行,将生成( )个字节码文件: A.      1 B. 3 C. 5 D. 4 7.下列关于线程说法错误的是() A.实现线程可以有2种方法 B.线程的实现中要重写run()方法 C.一个类实现线程可以继承自Runable类或实现Thread接口 D.类中调用线程可以使用匿名类调用start()方法启动线程 四. 写出如下程序运行结果:(每小题3分,共15分) 1.class lei {  public static void main(String[] args) {  int  i,j,m=0,n=0;  for(i=0;i<4;i++) {     m+=10; for(j=0;j<=i;j++) {  m=20; n=m+10; } } System.out.print(“n=”+n); } } __________________n=30_______________________________. 2.import java.util.*; public class a {        public static void main(String[] args)        {   int i=0;               String s="i am Tom,she is my gf,she is vary pretty,and I love her";               StringTokenizer fenxi=new StringTokenizer(s,",");               int number=fenxi.countTokens();               while(fenxi.hasMoreElements())               {             i++;                      String str=fenxi.nextToken();                      if(i<2) { System.out.println("还剩"+fenxi.countTokens()+"个单词");             }               }            } }请输入下列程序结果:________________________________________________. 3.  public class   a {        public static void main(String[] args)        {               char c[],d[];               String s="巴西足球队击败德国足球队";               c=new char[3];               s.getChars(3,5,c,0);               System.out.println(c);        } }请输入下列程序结果:__________________________________________________. 4. public class  a {        public static void main(String[] args)        {               int i =9;         int b=++i;         int c=i++;               System.out.println(i+” ”+b+” ”+c);        } } 结果 :_____________________11___10__10_______________________________. 5.  class Number {         int i; } class Assignment {        public static void main(String[] args)        {               Number n1,n2;               n1=new Number();               n2=new Number();                      n1.i=9;               n2.i=27;               System.out.print(n1.i+ “   ”+n2.i+ “   ”);               n1=n2;               System.out.print(n1.i+ “   ”+n2.i+ “   ”);               n2.i=69;               n2=n1;               System.out.print(n1.i+ “   ”+n2.i+ “   ”);                      } } 结果:___________________ 9    27   27   27   69   69 ___________________________________________.       五、编程题 (每空3分,共15分) 1. 程序填空(内部类实现接口): interface machine {        void run(); } class person {               void run(){                      System.out.println("正在工作");               } } class robot extends person { private class machineperson implements machine     {                          public void  run() {                      System.out.println("开始工作");               }               }        machine getmachine()        {               return ____________________________________; //返回一个接口类型变量        } } class text {        public static void main(String[] args)        {        robot r=new robot();    //实例化一个robot 对象r 。        machine m=_________________________________; //实例化一个machine 接口。        m.run();        r.run();                  } }   2.程序填空(对象上转型对象) class leirenyuan {        leirenyuan()        {        }        private int n=100;        void cryspeak(String s)        {               System.out.println(s);        }        void disp()        {               System.out.println(“I love b.m.w”);                               } } class people extends leirenyuan {               void computer(int a,int b)        {               int c=a*b;               System.out.println(c);                  }        void cryspeak(String s)        {            super.cryspeak("wonderful");               System.out.println("**"+s+"**");        } } class example4_21 {        public static void main(String[] args)        {               leirenyuan monkey=_______________________; //创建对象上转型对象               monkey.computer(); //请写出此语句错误原因____________________________________________。               monkey.cryspeak("i wanna fly");               monkey.disp();               people p=__________________; //将上转型对象强制转换为子类对象。               p.computer(3,8);        } }     六、编程题 (每小题10分,共30分)       1.从1-8之间随机输出4个无重复的整型数。(随机数函数:int     i=(int)(Math.random()*8+1);   )  

    最新回复(0)