下载此文档

华师大-网络程序设计-平时作业-.doc


文档分类:法律/法学 | 页数:约9页 举报非法文档有奖
1/9
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/9 下载此文档
文档列表 文档介绍
华师大-网络程序设计-平时作业-.doc《网络程序设计》
选择题
[1]假设有如下代码:答:C
public class Colors {
public static void main(String args[]) {
int n = 1;
("The Color is ” + args[n]);
} 「
}
,运行以下哪一条命令会产生输出 "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 blue green red yellow E. java green blue red yellow
[2]当编译和运行下列代码时会产生什么情况?答:B
public class StrEq {
private StrEq() {
String s = nBobn;
String s2 = new StringC'Bob");
if (s == s2){
("Equar,);
7・ }
else{
(nNot equal");
}
11・}
public static void main(String args[]){
StrEq s = new StrEq();
}
}
程序能通过编译并输出”Equal”.
程序能通过编译并输出”Not Equal”.
程序在编译时出错。
程序在运行时出错。
[3 ]对下列不完整的代码来说,哪些选项的声明语句能使程序完整并通过编 译?答:D、E
public class Declare {
2.
public static void main(String [] args) {
4.
("The variable is " + x);
}
7- }
Mint x;M放在第2行
nintx;n放在第4行
nintx = 5;n放在第2行
nintx = 5;n放在第4行
nstatic int x;H 放在第 2 行
nint x = new int();n 放在第 4 行

写一程序,它能接收命令行输入的2个整数,相加后将结果在屏幕上输出。 (注:输入的两个命令行参数分别对应aTgs[0]和args[l],但为String类型,可用 Integer类的parselnt方法来将它转换为整数后实现相加。例:
String strl;
int i;
strl = new String(n123n);
i = Integer. parselnt(str 1);
)一
答:主要程序代码如下:
Public class AddintegeM
public static void main(String[] args){
if(argsgth != 2)

华师大-网络程序设计-平时作业- 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数9
  • 收藏数0 收藏
  • 顶次数0
  • 上传人蓝天
  • 文件大小85 KB
  • 时间2021-10-22