public class foo {  public static void main (string[]args) 

题目
单选题
public class foo {  public static void main (string[]args)  try {return;}  finally {system.out.printIn(“Finally”);}  }  What is the result?()
A

 The program runs and prints nothing.

B

 The program runs and prints “Finally”

C

 The code compiles, but an exception is thrown at runtime.

D

 The code will not compile because the catch block is missing.

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

下列( )是对main ()主方法的正确表示。

A.public void static main (String args []) {…}

B.void public static main (String args []) {…}

C.static public void main (String args []) {…}

D.以上都不正确


正确答案:C

第2题:

以下是JAVA中正确的入口方法是? () 

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

正确答案:A

第3题:

以下Java应用程序执行入口main方法的声明中,正确的是( )。

A.public static void main()

B.public static void main(String[] args)

C.public static int main(String[] args)

D.public void main(String[] args)


参考答案:B

第4题:

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

  • A、 foofoofoofoofoo
  • B、 foobarfoobarbar
  • C、 foobarfoofoofoo
  • D、 foobarfoobarfoo
  • E、 barbarbarbarbar
  • F、 foofoofoobarbar
  • G、 foofoofoobarfoo

正确答案:D

第5题:

public class Test {   public static void main (String args) {  string foo = “blue”;  string bar = foo;   foo = “green”;   System.out.printIn(bar);   }   }   What is the result?()  

  • A、 An exception is thrown.
  • B、 The code will not compile.
  • C、 The program prints “null”
  • D、 The program prints “blue”
  • E、 The program prints “green”

正确答案:D

第6题:

以下哪个是Java应用程序main方法的有效定义?

A. public static void main();

B. public static void main( String args );

C. public static void main( String args[] );

D. public static void main( Graphics g );

E. public static boolean main( String a[] );


正确答案:C

第7题:

public class test(  public static void main(string[]args){  string foo = args [1];  string foo = args [2];  string foo = args [3];  }  )  And command line invocation: Java Test red green blue   What is the result?()  

  • A、 Baz has the value of “”
  • B、 Baz has the value of null
  • C、 Baz has the value of “red”
  • D、 Baz has the value of “blue”
  • E、 Bax has the value of “green”
  • F、 The program throws an exception.

正确答案:F

第8题:

下列哪个是对main( )主方法的正确表示?

A.public void static main(String args[ ]){ ... }

B.void public static main(String args[ ]){ ... }

C.static public void main(String args[ ]){ ... }

D.以上都不正确


正确答案:C
解析:在主方法定义时,应注意的是放在主方法前面的返回类型,一般都是void,在往前面是其他修饰符,一般为public和static,这两个修饰符的位置是可以互换的。public表示主方法可以被任意的Java对象访问,static表示该方法是静态方法即只能在类中使用,void是表示主方法没有返回类型,因为Java的类型检查很严格,一般的方法都有适当的返回值,对没有返回值的必须加void说明,每个应用程序必须有且仅有一个主方法。

第9题:

Which declarations will allow a class to be started as a standalone program?()  

  • A、public void main(String args[])
  • B、public void static main(String args[])
  • C、public static main(String[] argv)
  • D、final public static void main(String [] array)
  • E、public static void main(String args[])

正确答案:D,E

第10题:

Public class test (  Public static void main (String args[])  (  System.out.printIn (6 ^ 3);  )  )   What is the output?()


正确答案:5

更多相关问题