一、程序阅读题,写出以下程序的运行结果。(共 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();
}