电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

华东师大网络程序设计平时作业资料VIP免费

华东师大网络程序设计平时作业资料_第1页
1/9
华东师大网络程序设计平时作业资料_第2页
2/9
华东师大网络程序设计平时作业资料_第3页
3/9
《网络程序设计》一.选择题[ 1 ] 假设有如下代码:1. public class Colors { 2. public static void main(String args[]) { 3. int n = 1; 4. System.out.println("The Color is " + args[n]); 5. } 6. } 设程序已经通过编译并生成文件Colors.class,运行以下哪一条命令会产生输出"The Color is blue"? A. Colors red green blue yellow B. java Colors blue green red yellow C. java Colors green blue red yellow D. java Colors.class blue green red yellow E. java Colors.class green blue red yellow 答: C [ 2 ] 当编译和运行下列代码时会产生什么情况?1. public class StrEq { 2. private StrEq() { 3. String s = "Bob"; 4. String s2 = new String("Bob"); 5. if (s == s2){ 6. System.out.println("Equal"); 7. } 8. else{ 9. System.out.println("Not equal"); 10. } 11. } 12. public static void main(String args[]){ 13. StrEq s = new StrEq(); 14. } 15. } A. 程序能通过编译并输出"Equal". B. 程序能通过编译并输出"Not Equal". C. 程序在编译时出错。D. 程序在运行时出错。答: B [ 3 ] 对下列不完整的代码来说,哪些选项的声明语句能使程序完整并通过编译?1. public class Declare { 2. 3. public static void main(String [] args) { 4. 5. System.out.println("The variable is " + x); 6. } 7. } A. "int x;" 放在第 2 行B. "int x;" 放在第 4 行C. "int x = 5;" 放在第 2 行D. "int x = 5;" 放在第 4 行E. "static int x;" 放在第 2 行F. "int x = new int();" 放在第 4 行答: D,E 二.编程题1. 写一程序,它能接收命令行输入的2 个整数,相加后将结果在屏幕上输出。(注: 输入的两个命令行参数分别对应args[0]和 args[1],但为 String 类型,可用Integer 类的 parseInt 方法来将它转换为整数后实现相加。例:String str1; int i; str1 = new String("123"); i = Integer.parseInt(str1); ) 答:主要程序代码如下:public class Add2Integer { public static void main(String[] args) { if (args.length != 2) System.out.println("参数个数不对 !"); ...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

华东师大网络程序设计平时作业资料

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部