log4j.appender.stdout.Target=System.out
…
log4j.rootLogger=info, stdout, file
他在程序中这样编写,将会输出的日志信息是(C)。
logger.debug("记录debug日志");
http://www.doczj.com/doc/a18a502b915f804d2b16c14e.html("记录info日志");
A..记录debug日志记录info日志
B.记录debug日志
C.记录info日志
D.程序错误,无法输出日志
12、下面的异常处理代码的输出结果是(A)。
try{
int result = 6/0;
System.out.print("try,");
} catch(ArithmeticException e1) {
System.out.print("ArithmeticException异常,");
throw new Exception();
} catch(Exception e2) {
System.out.print("Exception异常,");
} finally {
System.out.print("finally");
}
A.程序错误BArithmeticException异常,finally
C.ArithmeticException异常,Exception异常,finally
D.try,ArithmeticException异常,Exception异常,finally
13、关于Java的接口,下面说法错误的是(D)。
A.可以被继承
B.可以只定义常量,而没有任何方法
C.可以这样定义常量:public int EVEREST = 8848;
D.方法的参数不可以是接口
14、下列代码的输出结果是(B)。
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 ");
System.out.println(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
15、能与public void methodA(){ }形成重载的有(C)。
A.private void methodA(){ }
B.private int methodA(){ return 1;}
C.public void methodA(int a){ }
D.public void methodA() throws Exception{ }
16、子类中能与父类public void methodA(int a){ }方法形成重写的有(D)。
A.public int methodA(int a){return 1;}
B.public void methodA(int a) throws Exception{ }
C.private void methodA(int a){ }
D.public void methodA(int b){ }
17、关于构造方法,下面说法错误的是(BC)。
A.父类只有一个带参的构造方法,子类必须显示声明带参构造方法
B.子类无参构造方法中没有写super();不会调用父类无参构造方法
C.子类无参构造方法不可以用super(int a);调用父类对应的带参构造方法
D.实例化一个类的对象时,一定会先调用http://www.doczj.com/doc/a18a502b915f804d2b16c14e.htmlng.Object的构造方法
18、阅读下面代码,将会输出(B)。
public class Testa {
Integer a = new Integer(10);
Integer b = new Integer(10);
public static void main (String[ ] args){
Testa testA = new Testa();
if (testA.a==testA.b){
System.out.print("很");
}
if (testA.a.equals(testA.b)){
System.out.print("好"); }}}