现有:  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) thro

题目

现有:  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、 运行时异常被抛出。

相似考题
更多“现有:  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) throw”相关问题
  • 第1题:

    在下列程序的划线处应填入的语句是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;


    正确答案:D
    解析:选项A)w没有被声明过,不能使用。选项B)虽然b是类Man的public成员变量,但是在静态方法中不能使用类中的非静态成员。选项C)a是类Person的private成员,在类外不能直接引用。选项D)b是类Man的public成员变量,且是int 型,可以通过类的实例变量t用并赋值给一个int型变量。

  • 第2题:

    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[])


    正确答案:B

  • 第3题:

    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[])


    正确答案:B

  • 第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);


    正确答案:D

  • 第5题:

    Which are syntactically valid statement at// point x?()     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;  // point x     }    } 

    • A、 i = m;
    • B、 i = b;
    • C、 i = p.a;
    • D、 i = p.change(30);
    • E、 i = t.b.

    正确答案:D,E

  • 第6题:

    现有:   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

  • 第7题:

    main方法是Java程序执行的入口点,关于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[] )

    正确答案:B

  • 第8题:

    现有:  class  Parser extends  Utilis  {  public static void main (String  []  args)  {  try  {  System. out.print (new  Parser ( ) .getlnt ("42")} ;     }  catch (NumberFormatException n) {  System.out .println ( "NFExc" ) ;   }     }  int getlnt (String arg)  throws NumberFormatException{    return Integer.parselnt (arg) ;     }     class Utils {  int getlnt (String arg)  {  return 42;  }    }  结果为 :()

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

    正确答案:B

  • 第9题:

    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

  • 第10题:

    单选题
    现有:  class  Parser extends  Utilis  {  public static void main (String  []  args)  {  try  {  System. out.print (new  Parser ( ) .getlnt ("42")} ;     }  catch (NumberFormatException n) {  System.out .println ( "NFExc" ) ;   }     }  int getlnt (String arg)  throws NumberFormatException{    return Integer.parselnt (arg) ;     }     class Utils {  int getlnt (String arg)  {  return 42;  }    }  结果为 :()
    A

     NFExc

    B

     42

    C

     42NFExc

    D

    编译失败


    正确答案: C
    解析: 暂无解析

  • 第11题:

    单选题
    定义类:      package utils;      public class Rep{  public static String twice (String s){return s+s ;}     }  再定义另一个类Demo:      //insert code here      public class Demo{  public static void main (String[]  args){      System. out .println( twice( "Hello"));      }      }  在第一行插入哪项代码,可以使程序正常编译和执行?()
    A

    import utils.*;

    B

     import utils.Rep.*;

    C

     import static utils.Rep.twice;

    D

     static import utils.Rep.twice;


    正确答案: C
    解析: 暂无解析

  • 第12题:

    单选题
    现有  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

    编译失败


    正确答案: B
    解析: 暂无解析

  • 第13题:

    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 来明确。

  • 第14题:

    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[])


    正确答案:B

  • 第15题:

    在下列程序的划线处应填入的语句是( )。 class Person { private int a: } public class Man extends Person{ public int b; public static void main(String arg []){ Person p=newPerson(); Man t=new Man(); int i; _________________ } }

    A.i=w;

    B.i=b;

    C.i=P.a;

    D.i=t.b;


    正确答案:D

  • 第16题:

    现有:  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

  • 第17题:

    现有  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

  • 第18题:

    main方法是Java应用程序执行的入口点,关于main方法的方法头以下哪项是合法的?()

    • A、public static void main()
    • B、public static void main(String[]args)
    • C、public static int main(String[]arg)
    • D、public void main(Stringarg[])

    正确答案:B

  • 第19题:

    class Parser extends Utils {  public static void main (String [] args) {  try { System.out.print(new Parser().getInt("42"));  } catch (NumberFormatException n) {  System.out.println("NFExc "); }  }  int getInt(String arg) throws NumberFormatException {  return Integer.parseInt(arg);  }  }  class Utils {  int getInt(String arg) { return 42; }  }  结果为:() 

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

    正确答案:A

  • 第20题:

    定义类:      package utils;      public class Rep{  public static String twice (String s){return s+s ;}     }  再定义另一个类Demo:      //insert code here      public class Demo{  public static void main (String[]  args){      System. out .println( twice( "Hello"));      }      }  在第一行插入哪项代码,可以使程序正常编译和执行?()     

    • A、import utils.*;
    • B、 import utils.Rep.*;
    • C、 import static utils.Rep.twice;
    • D、 static import utils.Rep.twice;

    正确答案:C

  • 第21题:

    单选题
    现有:  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
    解析: 暂无解析

  • 第22题:

    单选题
    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
    解析: 暂无解析

  • 第23题:

    单选题
    main方法是Java应用程序执行的入口点,关于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[] )


    正确答案: B
    解析: 暂无解析