直接上题,如下:
1.
class Happy {
public static void main(String args[]) {
int i = 1 ;
int j = i++ ;
if((i==(++j))&&((i++)==j)) {
i += j ;
}
System.out.println("i = "+i);
}
}
运行完上面代码之后输出i的值是多少?
A. 4
B. 5
C. 3
D. 6
2. 下面的数据声明及赋值那一个是没有错误的?
A. float f = 1.3;
B. char c = "a"
C. byte b = 257
D. int i = 10
3. 编译Java源程序文件产生的字节码文件的扩展名为?
A. java
B. class
C. html
D. exe
4. 现在假设有如下程序:
public class Demo {
public static void main(String args[]) {
boolean flag = 10%2 == 1 && 10 / 3 == 0 && 1 / 0 == 0 ;
System.out.println(flag ? "aliyunedu" : "yootk") ;
}
}
以上程序的最终执行结果是什么?
A. aliyunedu
B. yootk
C. true
D. 程序出错
5. 现在假设有如下程序:
public class Demo {
public static void main(String args[]) {
int x = 10 ;
double y = 20.2 ;
long z = 10L;
String str = "" + x + y * z ;
System.out.println(str) ;
}
}
以上程序的最终执行结果是什么?
A. 10202.0
B. 0212.0
C. 302.0
D. 1020.210
6. 现在假设有如下程序:
public class Demo {
public static void main(String args[]) {
String str = "" ;
for (int x = 0 ; x < 5 ; x ++) {
str += x ;
}
System.out.println(str) ;
}
}
以上程序最终的执行结果是什么?
A. 01234
B. 10
C. 14
D. 25
7. 现在假设有如下程序:
public class Demo {
public static void main(String args[]) {
System.out.println(inc(10) + inc(8) + inc(-10)) ;
}
public static int inc(int temp) {
if (temp > 0) {
return temp * 2 ;
}
return -1 ;
}
}
以上程序的最终执行结果是什么?
A. 35
B. 8
C. 28
D. 12
8. 现在假设有如下程序:
public class Demo {
public static void main(String args[]) {
char c = 'A' ;
int num = 10 ;
switch(c) {
case 'B' :
num ++ ;
case 'A' :
num ++ ;
case 'Y' :
num ++ ;
break ;
default :
num -- ;
}
System.out.println(num) ;
}
}
1.
class Happy {
public static void main(String args[]) {
int i = 1 ;
int j = i++ ;
if((i==(++j))&&((i++)==j)) {
i += j ;
}
System.out.println("i = "+i);
}
}
运行完上面代码之后输出i的值是多少?
A. 4
B. 5
C. 3
D. 6
2. 下面的数据声明及赋值那一个是没有错误的?
A. float f = 1.3;
B. char c = "a"
C. byte b = 257
D. int i = 10
3. 编译Java源程序文件产生的字节码文件的扩展名为?
A. java
B. class
C. html
D. exe
4. 现在假设有如下程序:
public class Demo {
public static void main(String args[]) {
boolean flag = 10%2 == 1 && 10 / 3 == 0 && 1 / 0 == 0 ;
System.out.println(flag ? "aliyunedu" : "yootk") ;
}
}
以上程序的最终执行结果是什么?
A. aliyunedu
B. yootk
C. true
D. 程序出错
5. 现在假设有如下程序:
public class Demo {
public static void main(String args[]) {
int x = 10 ;
double y = 20.2 ;
long z = 10L;
String str = "" + x + y * z ;
System.out.println(str) ;
}
}
以上程序的最终执行结果是什么?
A. 10202.0
B. 0212.0
C. 302.0
D. 1020.210
6. 现在假设有如下程序:
public class Demo {
public static void main(String args[]) {
String str = "" ;
for (int x = 0 ; x < 5 ; x ++) {
str += x ;
}
System.out.println(str) ;
}
}
以上程序最终的执行结果是什么?
A. 01234
B. 10
C. 14
D. 25
7. 现在假设有如下程序:
public class Demo {
public static void main(String args[]) {
System.out.println(inc(10) + inc(8) + inc(-10)) ;
}
public static int inc(int temp) {
if (temp > 0) {
return temp * 2 ;
}
return -1 ;
}
}
以上程序的最终执行结果是什么?
A. 35
B. 8
C. 28
D. 12
8. 现在假设有如下程序:
public class Demo {
public static void main(String args[]) {
char c = 'A' ;
int num = 10 ;
switch(c) {
case 'B' :
num ++ ;
case 'A' :
num ++ ;
case 'Y' :
num ++ ;
break ;
default :
num -- ;
}
System.out.println(num) ;
}
}
以上程序的最终执行结果是什么?
A. 11
B. 13
C. 12
D. 10
9. 现在假设有如下程序:
public class Demo {
public static void main(String args[]) {
int sum = 0 ;
for (int x = 1 ; x < 10 ; x ++) {
sum += x ;
if (x % 3 == 0) {
continue ;
}
}
System.out.println(sum) ;
}
}
A. 11
B. 13
C. 12
D. 10
9. 现在假设有如下程序:
public class Demo {
public static void main(String args[]) {
int sum = 0 ;
for (int x = 1 ; x < 10 ; x ++) {
sum += x ;
if (x % 3 == 0) {
continue ;
}
}
System.out.println(sum) ;
}
}
以上程序的最终执行结果是什么?
A. 6
B. 0
C. 程序错误,死循环
D. 45
10. 现在假设有如下程序:
public class Demo {
public static void main(String args[]) {
int sum = 0 ;
for (int x = 0 ; x < 10 ; x ++) {
sum += x ;
if (x % 3 == 0) {
break ;
}
}
System.out.println(sum) ;
}
}
A. 6
B. 0
C. 程序错误,死循环
D. 45
10. 现在假设有如下程序:
public class Demo {
public static void main(String args[]) {
int sum = 0 ;
for (int x = 0 ; x < 10 ; x ++) {
sum += x ;
if (x % 3 == 0) {
break ;
}
}
System.out.println(sum) ;
}
}
以上程序的最终执行结果是什么?
A. 6
B. 0
C. 程序错误,死循环
D. 45
A. 6
B. 0
C. 程序错误,死循环
D. 45
答案:BDBBA AACDB
你做对了多少呢?若想学习请到 http://click.aliyun.com/m/23565/
你做对了多少呢?若想学习请到 http://click.aliyun.com/m/23565/
本文转载自:阿里云云栖社区更多技术干货及好文,请关注
官方微博:@阿里云云栖社区 现在有免费赠手机的活动哦
官方微信:云栖社区(yunqiinsight)
官方知乎号:阿里云云栖社区