重庆自考网是公益服务信息网,供学习交流使用,非政府官方网站,官方信息以重庆教育考试院www.cqksy.cn为准。
您现在的位置:首页 >> 复习备考 >> 模拟试题 >> 工学类《2018年自考《Java语言程序设计》综合练习题四》

2018年自考《Java语言程序设计》综合练习题四

2022-05-25来源:重庆自考网

2018年自考《Java语言程序设计》综合练习题四

四、写出下面程序的运行结果。

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+' b='+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+' b='+b+' c='+c);  }

  }

  

4. import    java.io.*;

  public class abc

    {

         public static void main(String args[])

{

                String  s1 = 'Hello!';

                String  s2 = new String('World!');

                System.out.println(s1.concat(s2));

         }

     }

 

 

5.  import  java.io.* ;

public  class  ABC

  {

public  static  void   main(String  args[ ])

{  int   i  ;

         int  a[ ] = { 11,22,33,44,55,66,77,88,99 };

         for  ( i = 0 ; i

声明:

(一)由于考试政策等各方面情况的不断调整与变化,本网站所提供的考试信息仅供参考,请以权威部门公布的正式信息为准。

(二)本网站在文章内容来源出处标注为其他平台的稿件均为转载稿,免费转载出于非商业性学习目的,版权归原作者所有。如您对内容、版权等问题存在异议请与本站联系。邮箱:23006896@qq.com,我们会及时进行处理解决。

重庆自考时间

2025年自考时间:
04月12日

还有000

立即提升学历
  • 张**已获得升学规划方案!
  • 蒋**已获得升学规划方案!
  • 李**已获得升学规划方案!
  • 陈**已获得升学规划方案!
  • 赵**已获得升学规划方案!
  • 魏**已获得升学规划方案!
  • 严**已获得升学规划方案!
  • 贺**已获得升学规划方案!
  • 段**已获得升学规划方案!
  • 张**已获得升学规划方案!
  • 蒋**已获得升学规划方案!
  • 李**已获得升学规划方案!
  • 陈**已获得升学规划方案!
  • 赵**已获得升学规划方案!
  • 魏**已获得升学规划方案!
  • 严**已获得升学规划方案!
  • 贺**已获得升学规划方案!
  • 段**已获得升学规划方案!

  • 微信咨询

    微信咨询

    微信二维码
    留言