42
编译失败。
无输出结果。
运行时异常被抛出。
第1题:
现有:classParser(类)extends(继承)Utils{publicstaticvoidmain(String[]args){System.out.print(输出打印)(newParser().getInt("42"));}intgetInt(Stringarg){returnInteger.parseInt(arg);}}classUtils{intgetInt(Stringarg)throwsException{return42;}}结果为:()
A.42
B.编译失败。
C.无输出结果。
D.运行时异常被抛出。
第2题:
interface A{
int x = 0;
}
class B{
int x =1;
}
class C extends B implements A {
public void pX(){
System.out.println(x);
}
public static void main(String[] args) {
new C().pX();
}
}
错误。在编译时会发生错误(错误描述不同的JVM 有不同的信息,意思就是未明确的
x 调用,两个x 都匹配(就象在同时import java.util 和java.sql 两个包时直接声明Date 一样)。
对于父类的变量,可以用super.x 来明确,而接口的属性默认隐含为 public static final.所以可
以通过A.x 来明确。
第3题:
能将程序补充完整的选项是( )。class Person{ private int a; public int change(int m){ return m; }}public class Teacher extends Person{ public int b; public static void main(String arg[]) { Person p = new Person(); Teacher t = new Teacher(); int i; ______ }} B.
A.i=m
B.i=b
C. i=p.a
D.i=p. change(50)
第4题:
设有类定义如下:
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);
第5题:
main方法是JavaApplication程序执行的入口点。关于main方法的方法头,下列合法的是( )。
A.public static void main()
B. public static void main(String[])args)
C. public static iht main(String[]arg)
D.public void main(String arg[])
第6题:
在下列程序的划线处应填入的语句是class Person { private int a;}public class Man extends Person{ public int b; public static void main (String arg []){ Person p=new Person(); Man t=new Man(); int i: }}
A.i=w;
B.i=b
C.i=p.a;
D.i=t.b;
第7题:
main方法是Java Application程序执行的入口点,关于main方法头以下( )是合法的。
A.pubUc statk void main()
B.public static void main (String[]args)
C.public static int main (String[]arg)
D.public void main (String arg[])
第8题:
能将程序补充完整的选项是______。 class Person{ private int a; phblic int change(int m){return m;} } public class Teacher extends Person{ public int b; public static void main(String arg[ ]){ Person p=new Person( ); Teacher t=new Teacher( ); int i; ______; } }
A.i=m
B.i=b
C.i=p.a
D.i=p.change(50)
第9题:
main方法是Java Application程序执行的入口点,关于main方法头以下( )是合法的。
A.public static void main( )
B.public static void main (String[ ]args)
C.public static int main (String[ ]arg)
D.public void main(String arg[])
第10题:
现有: class Parser extends Utils { public static void main (String[] args) { try{System.out.print (new Parser().getlnt("42")); } catch (Exception e) { System.out.println("Exc"); } } int getlnt (String arg) throws Exception { return Integer.parselnt (arg); } class Utils { int getlnt (String arg) {return 42; } } 结果为()