以下代码运行结果是 class Exsuper{ String name; String nick_name; public Exsuper(String s,String t){ name = s; nick_name = t; } public String toString(){ return name; } } public class Example extends Exsuper { public Example(String s,String t){ super(s,t); } public String toString(){ return name+" a.k.a "+nick_name; } public static void main(String[] args) { Exsuper a = new Exsuper("First","1"); Example b = new Example("Second","2"); System.out.println("a is "+a.toString()); System.out.println("b is "+b.toString()); } }
A、编译错误
B、ClassCastException异常
C、输出 a is First b is Second
D、输出 a is First a.k.a 1 b is Second a.k.a 2
E、输出 a is First b is Second a.k.a 2
第1题
public class Example{
String str=new String("good");
char[] ch={'a','b','c'};
public static void main(String args[]){
Example ex=new Example();
ex.change(ex.str,ex.ch);
System.out.print(ex.str+" and ");
Sytem.out.print(ex.ch);
}
public void change(String str,char ch[]){
str="test ok";
ch[0]='g';
}
}
A. good and abc
B. good and gbc
C. test ok and abc
D. test ok and gbc
第2题
public classexample{
public static void main(string[] args) {
string[] strs = { "tom", "jerry","donald" };
for (string str : strs) {
str = "tuffy"
}
system.out.println(strs[0] + "," + strs[1] +","
+ strs[2])
}
}
A、Tom,Jerry,Donald
B、Tuffy,Jerry,Donald
C、Tuffy,Tuffy,Tuffy
D、发生异常,输出异常信息
第3题
A.this.commission=commission;
B.superb();commission=commission;
C.this.commission=commission;superb();
D.super(name,baseSalary);this.commission=commission;
E.super();this.commission=commission;
F.this.commission=commission;super(name,baseSalary);
第5题
A、行4
B、行8
C、行13
D、行17
E、行18
第6题
A、123
B、123+4+5
C、1239
D、编译时发生异常
第8题
A、<class 'int'>
B、<class 'str'>
C、<class 'float'>
D、<class 'char'>
第10题
A、Goodmorning
B、gOODmORNING
C、goodmorning
D、goodMORNING
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!