桂林理工大学JAVA试卷(2021)

本文提供了桂林理工大学2021年JAVA课程的考试题目及参考答案,包括程序阅读理解、程序填空和程序设计题,涵盖了JAVA的基础知识和面向对象编程的应用。考生需理解JAVA程序的运行逻辑,掌握循环、异常处理、数组操作、类与对象的使用等核心概念。
摘要由CSDN通过智能技术生成

一、程序阅读题,写出以下程序的运行结果。(共 5 道题,每题 6 分,共 30 分)
1.class Tester{
public static void main(String[] args){
int x =12, y = 5;
System.out.println(x + y + "=" + x + y);
}
}
2. public class Tester{
public static void main(String args[]) {
int total = 0;
for ( int i = 0; i < 10; i ++) {
total += i;
if (i % 5 == 3)
break;
total += i;
}
System.out.println ("total = " + total );
}
}
3. public class TestClass{
private static int fun(int[][] data){
int value = data[0][0];
for (int i = 0; i < data.length; i ++)
for (int j = 0; j < data[i].length; j ++)
if (data[i][j] < value)
value = data[i][j];
return value;
}
public static void main(String[] args){
int[][] data = { {9, 2, 5}, {2, 6}, {3, 9, 7, 2}};
System.out.println(fun(data));
}
}

4. public class Base{
public Base(){System.out.print("1") ;}
public void show(){ System.out.print("2") ;}
}
public class Deprive extends Base{
public Deprive(){System.out.print("3") ;}
public void show(){
System.out.print("4");
}
public static void main(String[] args){
Base b = new Deprive();
b.show();
}

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值