• 2021-04-14
    在命令行输入如下命令,结果为java myprog good morningpublic class myprog{public static void main(String argv[]) {System.out.println(argv[2]);}}
  • 出现异常 "java.lang.ArrayIndexOutOfBoundsException: 2"

    内容

    • 0

      main函数也可以写为public static void main( String…argv){}。 A: 正确 B: 错误

    • 1

      中国大学MOOC: main函数也可以写为public static void main( String…argv){}。

    • 2

      中国大学MOOC: 下列代码中构造方法的返回类型是()public class Village { Village () { System .out .println(“hiding in Village”) ; } public static void main( String args [ ]) { Village c =new Village ( ) ;}class Village { public static void main( String args [ ]) { Village c =new Village ( ) ; } Village () { System .out .println(“hiding in Village”) ; } }

    • 3

      当你编译运行下列程序代码,会得到什么结果? 。 private class Base{ Base(){ int i = 100; System.out.println(i); } } public class Pri extends Base{ static int i = 200; public static void main(String argv[]){ Pri p = new Pri(); System.out.println(i); } }

    • 4

      以下代码调试结果 class Base {} class Sub extends Base {} public class CEx{ public static void main(String argv[]){ Base b = new Base(); Sub s = (Sub) b; } }