问答题
本程序使用分支语句来控制输出,已知初始状态字符变量ch=’A’,整型变量r=6,并且输出结果是:r=5。 public class exam_3{ public static void main(______){ char ch=’A’; int r=6; ______(ch+1){ case ’A’: r=r+3; case ’B’: r=r+5; case ’C’: ______ default : r=r*2; } System.out.println("r="+r); } }
【参考答案】
String[] args(或String args[])(注:args为变量名,可为其他名称) switch r=r-......
(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)
点击查看答案
<上一题
目录
下一题>
热门
试题
问答题
本程序的功能是判断年份1990、2000和2008是否是闰年,并打印输出判断结果。public class exam_2{public static void main(String[] args){yes_no(1990);yes_no(2000);yes_no(2008);}public______yes_no(int year){if(______)System.out.print(year+ 年是闰年。 );______System.out.print(year+ 年不是闰年。 );}}
点击查看答案
问答题
下列程序中定义了一个长度为20的整数数组,然后将1~20分别赋给数组元素,计算该数组中所有元素的和。public class exam_1{public static void main(String args[]){int sum;______;int arrayList[]=new int[20];for(int i=0; i<=19; i++)arrayList[i]=i+1;int pos=0;while(pos<20){if(______)sum=sum+arrayList[pos];______;}System.out.println( sum= +sum);}}
点击查看答案
相关试题
本程序的功能是判断年份1990、2000...
下列程序中定义了一个长度为20的整数数组...