现有:      class Cat  {      Cat (int c)  {System.out.print {"cat"+c+" ");  }      }      class SubCat extends Cat  {      SubCat (int c){super (5); System.out.print ("cable");}      SubCat()  {  this (4);  }      public static void main (String  []  args) 

题目

现有:      class Cat  {      Cat (int c)  {System.out.print {"cat"+c+" ");  }      }      class SubCat extends Cat  {      SubCat (int c){super (5); System.out.print ("cable");}      SubCat()  {  this (4);  }      public static void main (String  []  args)  {      SubCat s= new SubCat();      }      }     结果为:()     

  • A、 cat5
  • B、 cable
  • C、 cat5 cable
  • D、 cable cat5
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第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;  }      }      结果为()    

  • A、 42
  • B、 Exc
  • C、 42Exc
  • D、编译失败

正确答案:D

第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


参考答案:D

第4题:

class Flibitz {   public static void main(String [] args) {   int grop = 7;   new Flibitz().go(grop);   System.out.print(grop);   }   void go(int grop) {   if(++grop 〉 7) grop++;   System.out.print(grop);   }   }   结果为:()  

  • A、77
  • B、79
  • C、97
  • D、99

正确答案:C

第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?()  

  • A、 4, 4
  • B、 4, 5
  • C、 5, 4
  • D、 5, 5
  • E、 The code will not compile.

正确答案:E

第6题:

以下程序调试结果为:class Base{Base(){int i = 100;System.out.print (i);}}public class Pri extends Base{static int i = 200;public static void main(String argv[]){Pri p = new Pri();System.out.print(i);}}

A.编译错误

B.200

C.100200

D.100


正确答案:C

第7题:

现有:  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; }  }   结果为:()  

  • A、 42
  • B、 编译失败。
  • C、 无输出结果。
  • D、 运行时异常被抛出。

正确答案:A

第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


参考答案:C

第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;  }     }  结果是什么?()      

  • A、 42Exc
  • B、 Exc
  • C、 42
  • D、编译失败

正确答案:C

第10题:

现有:   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; }    }    结果为()  

  • A、 42
  • B、 编译失败。
  • C、 无输出结果。
  • D、 运行时异常被抛出。

正确答案:A

更多相关问题