多项选择题
本程序的功能是定义类中带有参数的构造方法exam_19()和普通方法printInfo(),并定义类的对象temp,程序中将字符串“Jim”和整数19在定义对象时作为构造方法的参数传递给类,然后调用方法printInfo()打印传递的变量(如Jim已经有19岁了),请将程序中空缺部分填写适当内容,使程序能正确运行。
public class exam_19{
String name;
int age;
public exam_19(______){
this.name=name;
this.age=age;
}
______printInfo(){
System.out.println(name+"已经有"+age+"岁了.");
}
public static void main(String[] args){
String name="Jim";
int age=19;
______=new exam_19(name, age);
temp.printInfo();
}
}
热门
试题
问答题
本程序的功能是计算二维数组各个元素的和。程序中定义了二维数组arr,arr有3行4列共12个元素,程序中采用for循环语句的嵌套来计算数组中各个元素的和,并将结果保存在sum变量中,最后打印输出计算结果。public class exam_20{public static void main(String[] args){int arr[] []={{1,2,3,4}, {5,6,7,8}, {9,10,11,12}};int sum=0;int i=0, j=0;for(i=0; ______)for(______)______;System.out.println( sum= +sum);}}