栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

java程序设计基础题期末考试

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

java程序设计基础题期末考试

四、 简答题 (共6题,30分)

1、写出下列程序的运行结果____01234_____

 public class X3_3_1 {    

public static void main(String[] args) {

for(int i=0; i<10; i++){

      if(i==5) break;

       System.out.print(i);

      }

   }

}

(5.0)

正确答案:01234 

 

2、写出下列程序的运行结果__________。

public class X3_1 {

public static void main(String args[]){

System.out.println("This is my first Java Application!");

    }

}

(5.0)

正确答案:This is my first Java Application!

 

3、public class X3_3_8 {    

public static void main(String[] args) {

    char ch='7';

    int r=10;

    switch(ch+1){

     case '7': r += 7;

     case '8': r += 8;

     case '9': r += 9;

     default:

    }

    System.out.print(r);

}

}

 

 

4、public class fff

{

void printValue(int m)

{

do { System.out.println("The value is"+m);}

while( --m > 10 )

}

public static void main(String arg[])

{

int i=10;

Test t= new Test();

t.printValue(i);

}

}

(5.0)

正确答案: The value is10

 

5、写出下列代码执行后的输出结果_______。

int a=19,b=8;

int x=(a%b>5)? a+b:a-b;

System.out.println(x);

(5.0)

正确答案: 11

 

6、请在下方插入处插入合适的代码:________________

public class T{

int r;

int s;

T(int x,int y){

r=x;

s=y;

}

}

class S extends T{ int t;

public S(int x,int y,int z){ //插入代码处:要求插入代码实现 r=x,s=y

t=z;

}

}

(5.0)

正确答案: super(x,y);

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/992097.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号