cat5
cable
cable cat5
cat5 cable
第1题:
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 来明确。
第2题:
现有: 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; } } 结果为()
第3题:
现有:classCat{Cat(intc){System.out.print("cat"+c+"");}}classSubCatextendsCat{SubCat(intc){super(5);System.out.print("cable");}SubCat(){this(4);}publicstaticvoidmain(String[]args){SubCats=newSubCat();}}结果为:()
A.cat5
B.cable
C.cablecat5
D.cat5cable
第4题:
现有: class Parser extends Utils { public static void main(String [] args) { System.out.print(new Parser().getInt("42")); } int getInt(String arg) { return Integer.parseInt(arg); } } class Utils { int getInt(String arg) throws Exception { return 42; } } 结果为()
第5题:
class super { public int getLength() {return 4;} } public class Sub extends Super { public long getLength() {return 5;} public static void main (String[]args) { super sooper = new Super (); Sub sub = new Sub(); System.out.printIn( sooper.getLength()+ “,” + sub.getLength() }; } What is the output?()
第6题:
A.编译错误
B.200
C.100200
D.100
第7题:
public class Base { public static final String FOO = “foo”; public static void main(String[] args) { Base b = new Base(); Sub s = new Sub(); System.out.print(Base.FOO); System.out.print(Sub.FOO); System.out.print(b.FOO); System.out.print(s.FOO); System.out.print(((Base)s).FOO); } } class Sub extends Base {public static final String FOO=bar;} What is the result?()
第8题:
现有:classCat{Cat(intc){System.out.print{"cat"+c+"");}}classSubCatextendsCat{SubCat(intc){super(5);System.out.print("cable");}SubCat(){this(4);}publicstaticvoidmain(String[]args){SubCats=newSubCat();}}结果为:()
A.cat5
B.cable
C.cat5cable
D.cablecat5
第9题:
现有 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 () { return 42; } } 结果是什么?()
第10题:
class Super { public int i = 0; public Super(String text) { i = 1; } } public class Sub extends Super { public Sub(String text) { i = 2; } public static void main(String args[]) { Sub sub = new Sub(“Hello”); System.out.println(sub.i); } } What is the result?()