设有类定义如下:
class Base{
public Base(int i){}
}
public class MyOver extends Base{
public static void main(String arg[]){
MyOver m = new MyOver(10);
}
MyOver(int i){
super(i);
}
MyOver(String s, int i){
this(i);
//Here
}
}
以下哪条语句可以安排在//Here处 ?
A.MyOver m = new MyOver();
B.super();
C.this("Hello",10);
D.Base b = new Base(10);
第1题
以下程序调试结果为:
public class Test {
int m=5;
public void some(int x) {
m=x;
}
public static void main(String args []) {
new Demo().some(7);
}
}
class Demo extends Test {
int m=8;
public void some(int x) {
super.some(x);
System.out.println(m);
}
}
A.5
B.8
C.7
D.无任何输出
E.编译错误
第2题
以下程序的调试结果为?
public class Outer{
public String name = "Outer";
public static void main(String argv[]){
Inner i = new Inner();
i.showName();
}
private class Inner{
String name =new String("Inner");
void showName(){
System.out.println(name);
}
}
}
A.输出结果 Outer
B.输出结果 Inner
C.编译错误,因Inner类定义为私有访问
D.在创建Inner类实例的行出现编译错误
第3题
关于以下程序段,正确的说法是
1. String s1="Hello";
2. String s2="Hello";
3. if(s1= =s2、
4. System.out.println("s1= =s2");
5. if (s1.equals(s2、)
6. System.out.println("s1.equals(s2、");
A. 行4与行6都将执行
B. 行4执行,行6不执行
C. 行6执行,行4不执行
D. 行4、行6都不执行
第4题
A. 0
B. 1
C. No Object
D. 编译错误
E. null
第5题
A. if (a) { }
B. if (a<<3、{ }
C. if (a= 2、{ }
D. if (true) { }
第6题
设有如下类:
class MyPoint {
void myMethod() {
int x, y;
x = 5; y = 3;
System.out.print( " ( " + x + ", " + y + " ) " );
switchCoords( x, y );
System.out.print( " ( " + x + ", " + y + " ) " );
}
void switchCoords( int x, int y ) {
int temp;
temp = x;
x = y;
y = temp;
System.out.print( " ( " + x + ", " + y + " ) " );
}
}
如果执行myMethod()方法,则输出结果为?
A. (5, 3、(5, 3、(5, 3、
B. (5, 3、(3, 5、(3, 5、
C. (5, 3、(3, 5、(5, 3、
第7题
A. hello
B. hello2
C. 编译报错
D. 运行报错,不能将串与整数相加
第8题
设有如下类
class Loop{
public static void main(String[] agrs) {
int x=0;int y=0;
outer:
for(x=0;x<100;x++){
middle:
for(y=0;y<100;y++){
System.out.println("x="+x+"; y="+y);
if(y==10){<<>>}
}
}
}
}
在<<>>处插入什么代码可以结束外循环?
A.continue middle;
B.break outer;
C.break middle;
D.continue outer;
E.none of these
第9题
以下程序的运行结果为?
class xyz {
public static void main(String args[]) {
int i,j,k;
for (i = 0; i< 3; i++) {
for(j=1; j< 4; j++) {
for(k=2; k<5; k++) {
if((i == j) && (j==k))
System.out.println(i);
}
}
}
}
}
A. 0
B. 1
C. 2
D. 3
E. 4
第10题
以下程序的输出结果为:
public class test {
public static void main(String args[]) {
int s=0;
for (int k=0;k<=10;k++)
s+=method(2,k)-1;
System.out.println(s);
}
public static int method(int n,int m) {
if (m==0)
return 1;
else
return n*method(n,m-1、;
}
}
A. 2048
B. 1024
C. 2036
D.2000
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!