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

📄 java.txt

📁 java 的模拟题 个人收集
💻 TXT
📖 第 1 页 / 共 3 页
字号:
《JAVA语言程序设计》期末考试模拟试题

( 适用对象:成人专科、开放专科计算机类专业 )

 

2001年6月         

 

 

一、单选择题(每小题2分,共10分)

1、编译Java  Application 源程序文件将产生相应的字节码文件,这些字节码文件的扩展名为(      )。

         A.    .java                      B.    .class

         C.    .html                      D.    .exe

2、设 x = 1 , y = 2 , z = 3,则表达式  y+=z--/++x  的值是(      )。

         A.    3                        B.    3. 5

         C.    4                        D.    5

3、在Java  Applet程序用户自定义的Applet子类中,一般需要重载父类的(      )方法来完成一些画图操作。

    A.   start( )                    B.   stop( )

    C.   init( )                     D.   paint( )

4、不允许作为类及类成员的访问控制符的是(      )。

    A.   public                    B.   private

    C.   static                     D.   protected

5、为AB类的一个无形式参数无返回值的方法method书写方法头,使得使用类名AB作为前缀就可以调用它,该方法头的形式为(      )。

    A.  static  void  method( )                    B. public  void  method( )    

    C. final  void  method( )                      D. abstract  void  method( )

 

二、填空题(每空格1分,共20分)

1、开发与运行Java程序需要经过的三个主要步骤为                           、

                                 和                                      。

2、如果一个Java  Applet源程序文件只定义有一个类,该类的类名为MyApplet,则类MyApplet必须是                          类的子类并且存储该源程序文件的文件名为                                   。

3、如果一个Java  Applet程序文件中定义有3个类,则使用Sun公司的JDK编译

器              编译该源程序文件将产生                      个文件名与类名相同而扩展名为                    的字节码文件。

4、在Java的基本数据类型中,char型采用Unicode编码方案,每个Unicode码占

用                字节内存空间,这样,无论是中文字符还是英文字符,都是占

用               字节内存空间。

5、设 x = 2 ,则表达式 ( x + + )/3 的值是                 。

6、若x = 5,y = 10,则x < y和x >= y的逻辑值分别为           和           。

7、               方法是一种仅有方法头,没有具体方法体和操作实现的方法,该方法必须在抽象类之中定义。            方法是不能被当前类的子类重新定义的方法。

8、创建一个名为 MyPackage 的包的语句是                                     ,

该语句应该放在程序的位置为:                                             。

9、设有数组定义:int   MyIntArray[ ] = { 10 , 20 , 30 , 40 , 50 , 60 , 70};   则执行以下几个语句后的输出结果是                      。

     int  s = 0 ;

    for  ( int  i = 0 ; i < MyIntArray.length ; i + + )

                 if  ( i % 2 = = 1 )    s += MyIntArray[i] ;

   System.out.println( s );

10、在Java程序中,通过类的定义只能实现          重继承,但通过接口的定义可以实现        重继承关系。

 

三、写出下列程序完成的功能。(每小题5分,共20分)

 

1、public  class   Sum

{  public  static  void   main( String  args[ ])

   {   double   sum = 0.0 ;

       for  ( int  i = 1 ;  i <= 100 ; i + + )

           sum += 1.0/(double) i ;

      System.out.println( "sum="+sum );

   }

}

 

2、 import  java.io.* ;

    public  class  Reverse

    {   public  static  void   main(String  args[ ])

        {   int   i , n =10 ;

            int  a[ ] = new int[10];

            for  ( i = 0 ; i < n ; i ++ )

            try {

                 BufferedReader  br = new BufferedReader(

                         new  InputStreamReader(System.in));

                 a[i] = Integer.parseInt(br.readLine( ));  // 输入一个整数

            } catch ( IOException  e ) { } ;

            for  ( i = n-1 ; i >= 0 ; i ―― )

                System.out.print(a[i]+"  ");

        System.out.println( );

        }

   }

 

3、 import     java.awt.*;

    public    class    abc

    {  public   static   void    main(String args[])

          {      new FrameOut();       }

    }

    class   FrameOut   extends    Frame     //  Frame为系统定

     {   Button btn;                                        //  义的窗框类

         FrameOut( )

         {       super("按钮");

                 btn = new  Button("按下我");

                 setLayout(new   FlowLayout( ));

                 add(btn);

                 setSize(300,200);

                 show( );

          }

      }

 

4、import    java.io.*;

   public    class   abc

   {   public   static   void   main(String args[])

         {   SubClass    sb = new   SubClass( );        

             System.out.println(sb.max( ));

         }

     }

    class    SuperClass

   {   int  a = 10 , b = 20 ;  }

   class  SubClass  extends  SuperClass

   {   int  max( ) {  return   ((a>b)?a:b);  }  }

 

四、写出下面程序的运行结果(每小题10分,共30分)

1、 import    java.io.*;

public  class  abc

{         public  static  void  main(String args[ ])

          {    AB  s = new  AB("Hello!","I love JAVA.");

               System.out.println(s.toString( ));

          }

}

class   AB {

  String   s1;

  String   s2;

  AB( String  str1 , String  str2 )

  {  s1 = str1;  s2 = str2; }

  public   String   toString( )

  { return  s1+s2;}

}

 

2、 import    java.io.* ;

    public   class  abc

    {

          public   static   void    main(String  args[ ])

          {    int   i , s = 0 ;

               int  a[ ] = { 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 };

               for  ( i = 0 ; i < a.length ; i ++ )

                     if ( a[i]%3 = = 0 )  s += a[i] ; 

               System.out.println("s="+s);

           }

     }

 

3、import   java.io.* ;

      public  class  abc

     {

              public  static  void   main(String  args[ ])

             {  SubSubClass  x = new  SubSubClass(10 , 20 , 30);

                 x.show();

                }

     }

    class  SuperClass

    {  int  a,b;

        SuperClass(int aa , int  bb)

         {  a=aa;  b=bb;  }

       void  show( )

        {  System.out.println("a="+a+"\nb="+b);  }

    }

    class   SubClass   extends   SuperClass

    {  int c;

       SubClass(int  aa,int  bb,int  cc)

       {   super(aa,bb);

           c=cc;

       }

    }

⌨️ 快捷键说明

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