|  |  需要购买此门答案请加qq2762169544(微信:2762169544)
 
| 北航《Java语言与面向对象程序设计》考核要求
 
 一、填空题(每空4分,共20分)
 1. 设x = 2 ,则表达式 ( x + + ) * 3 的值是____________。
 2. 当整型变量n的值不能被13除尽时,其值为 false 的Java语言表达式是____________ 。
 3. 以下方法 m 的功能是求两参数之积的整数部分。
 int m ( float x, float y )
 { _______________; }
 4. 设 x = 2 ,则表达式 ( x + + )/3 的值是____________ 。
 5. 设有数组定义: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分,共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( );
 }
 }
 三、读程序题,写出程序运行结果(每小题15分,共30分)
 1. 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);
 }
 }
 2.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;
 }
 }
 class    SubSubClass    extends    SubClass
 {    int   a;
 SubSubClass(int aa,int   bb,int   cc)
 {    super(aa,bb,cc);
 a=aa+bb+cc;
 }
 void   show()
 {   System.out.println("a="+a+"\\nb="+b+"\\nc="+c);   }
 }
 四、编程题(每小题15分,共30分)
 1.编写一个字符界面的Java Application 程序,接受用户输入的10个整数,并输出这10个整数的最大值和最小值。
 2.输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。
 
 
 
 | 
 |