网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

编译下面代码将会发生的错误是() public class MyClass{ public static void main(String arguments[]){ amethod(arguments); } public void amethod(String[] arguments){ System.out.println(arguments); System.out.println(arguments[1]); } }

A.main方法体中不能调用amethod方法

B.main方法的参数声明不合法

C.数组访问时必须包含下标值

D.amethod方法的返回类型应该为String


参考答案和解析
C 解析:局部变量在使用前必须进行初始化,而代码中的变量k在使用前没有进行初始化。
更多 “编译下面代码将会发生的错误是() public class MyClass{ public static void main(String arguments[]){ amethod(arguments); } public void amethod(String[] arguments){ System.out.println(arguments); System.out.println(arguments[1]); } }A.main方法体中不能调用amethod方法B.main方法的参数声明不合法C.数组访问时必须包含下标值D.amethod方法的返回类型应该为String” 相关考题
考题 下面程序段的输出结果为 public class MyClass { public static void main(String args[]) { String s="Helto! How are you?"; System.out.println(s.lastlndexOf("o",16)); } }A.16B.oC.uD.17

考题 下列代码的编译或执行结果是______。public class MyVal{puhlic static void main(String args[]){MyVal m=new MyVal();m.aMethod();}public void aMethod(){boolean b[]=new Boolean[5];System.out.println(b[0]);}A) 1B) nullC) 0D) 编译错误A.B.C.D.

考题 下列程序的执行结果是 ( ) public class Test { public int aMethod() { satic int i=0; i++; System.out.println(i); } public static void.main(String args[]) { Test test=new Test(); test.aMethod(); }A.编译错误B.0C.1D.运行成功,但不输出

考题 下列代码的执行结果是public class Test{ public int aMethod(){ static int i=0; i++; System.out.println(i); } public static void main(String args[]){ Test test= new Test(); test. aMethod(); }}A.编译错误B.0C.1D.运行成功,但不输出

考题 阅读下面代码 public class Test { String s="One World One Dream"; public static void main(String[] args) { System.out.println(s); } } 其运行的结果是A.argsB.World One DreamC.sD.编译时出错

考题 阅读下面代码 public class Test { public static void main(String avgs[]) { System.out.println(89>>1); } } 其运行结果是A.44B.45C.88D.90

考题 阅读下面程序 public class My Val{ public static void main(String args[]){ My Val m=new My Val(); m. amethod(); } public void amethod(){ boolean b[]=new Boolean[5]; } } 程序编译或运行结果是A.1B.nullC.D.编译不能过

考题 下列代码的编译或执行结果是( )。 public class Myval{ public static void main(string args[]){ MyVal m=new MyVal; aMethod; } public void aMethod{ boolean b[]=new Boolean[5]; System.OUt.println(b[0]); } }A.1B.nullC.0D.编译错误

考题 下列代码的执行结果是( )。public class Test{public int aMethod( ){static int i=0;i++;System.out.println(i):}public static void main (String args[]){Trest test=new Test ( );test aMethod( ):}}A.编译错误B.0C.1D.运行成功,但不输出B.C.D.

考题 阅读下面程序 public class MyVal { public static void main(String[]args) { MyVal m=new MyVal(); m.amethod(); } public void amethod() { boolean b[]=new Boolean[5]; } } 程序编译或运行的结果是A.1B.nullC.""D.编译不通过

考题 以下的程序的调试结果为?public class MyAr{public static void main(String argv[]) {MyAr m = new MyAr();m.amethod();}public void amethod(){static int i;System.out.println(i);}} A. 输出结果为 0B. 运行出错C. 输出结果为 nullD. 编译错误

考题 以下程序的编译和运行结果为?abstract class Base{abstract public void myfunc();public void another(){System.out.println("Another method");}}public class Abs extends Base{public static void main(String argv[]){Abs a = new Abs();A.amethod();}public void myfunc(){System.out.println("My Func");}public void amethod(){myfunc();}}A.输出结果为 My FuncB.编译指示 Base 类中无抽象方法C.编译通过,但运行时指示Base 类中无抽象方法D.编译指示Base 类中的myfunc方法无方法体,没谁会喜欢该方法。

考题 以下程序的调试结果为?class Base{public final void amethod(){System.out.println("amethod");}}public class Fin extends Base{public static void main(String argv[]){Base b = new Base();b.amethod();}} A.编译指示带有final 方法的类自己必须定义为finalB.编译指示不能继承含有final 方法的类C.运行错误,原因是Base类没有定义为final类D.运行输出 amethod

考题 以下的程序的调试结果为?public class As{int i = 10;int j;char z= 1;boolean b;public static void main(String argv[]){As a = new As();A.amethod();}public void amethod(){System.out.println(j);System.out.println(b);}}A.输出0 和falseB. 输出0 和trueC. 编译错误,b 未初始化D. 编译错误, z 必须赋字符值

考题 { public static void main(String args[]) { System.out.println(MyClass1.data); } } class MyClass1 { int data=10; } 。() 此题为判断题(对,错)。

考题 执行以下代码,输出结果的结果是? () public class Test{  public String[] ss = new String[5];    public static void main(String[] args){      System.out.println(ss[1]);  } } A、 nullB、 -1C、 编译时出错D、 运行时报错

考题 执行以下代码后,下面哪些描述是正确的() public  class  Student{  private String name = “Jema”;  public void setName(String name){  this.name = name;  }  public String getName(){  return this.name;  }  public static void main(String[] args){  Student s;  System.out.println(s.getName()); } }A、输出nullB、第10行编译报错C、第11行编译报错D、输出Jema

考题 public class Test {  public static void aMethod() throws Exception {  try {  throw new Exception(); } finally {  System.out.println(“finally”);  }  }  public static void main(String args[]) {  try {  aMethod();  } catch (Exception e) {  System.out.println(“exception”);  }  System.out.println(“finished”);  }  }  What is the result?()  A、 finallyB、 exception finishedC、 finally exception finishedD、 Compilation fails.

考题 public class X {  public X aMethod() { return this;}  }  public class Y extends X {  }  Which two methods can be added to the definition of class Y?()A、 public void aMethod() {}B、 private void aMethod() {}C、 public void aMethod(String s) {}D、 private Y aMethod() { return null; }E、 public X aMethod() { return new Y(); }

考题 public class Test {  public int aMethod() {  static int i = 0;  i++;  return i;  }  public static void main (String args[]) {  Test test = new Test();  test.aMethod();  int j = test.aMethod();  System.out.println(j);  }  }  What is the result?()  A、 0B、 1C、 2D、 Compilation fails.

考题 现有:      class TestA  {  public void start()  {  System.out.println("TestA");  }     }  public class TestB extends TestA  {  public void start()  {  System.out.println("TestB");  }     public static void main (string[]  args)  (     ((TestA)new TestB()).start();     )     }  运行结果是哪项?()     A、  TeStAB、  TeStBC、编译失败D、运行时抛出异常

考题 Which code fragments will succeed in printing the last argument given on the command line to the standard output, and exit gracefully with no output if no arguments are given?()   CODE FRAGMENT a:   public static void main(String args[]) {   if (args.length != 0)   System.out.println(args[args.length-1]);   }   CODE FRAGMENT b:   public static void main(String args[]) {   try { System.out.println(args[args.length]); }   catch (ArrayIndexOutOfBoundsException e) {}   }   CODE FRAGMENT c:   public static void main(String args[]) {   int ix = args.length;   String last = args[ix];   if (ix != 0) System.out.println(last);   }   CODE FRAGMENT d:   public static void main(String args[]) {   int ix = args.length-1;   if (ix  0) System.out.println(args[ix]);   }   CODE FRAGMENT e:   public static void main(String args[]) {   try { System.out.println(args[args.length-1]);  }catch (NullPointerException e) {}   }  A、Code fragment a.B、Code fragment b.C、Code fragment c.D、Code fragment d.E、Code fragment e.

考题 单选题Which code fragments will succeed in printing the last argument given on the command line to the standard output, and exit gracefully with no output if no arguments are given?()   CODE FRAGMENT a:   public static void main(String args[]) {   if (args.length != 0)   System.out.println(args[args.length-1]);   }   CODE FRAGMENT b:   public static void main(String args[]) {   try { System.out.println(args[args.length]); }   catch (ArrayIndexOutOfBoundsException e) {}   }   CODE FRAGMENT c:   public static void main(String args[]) {   int ix = args.length;   String last = args[ix];   if (ix != 0) System.out.println(last);   }   CODE FRAGMENT d:   public static void main(String args[]) {   int ix = args.length-1;   if (ix  0) System.out.println(args[ix]);   }   CODE FRAGMENT e:   public static void main(String args[]) {   try { System.out.println(args[args.length-1]);  }catch (NullPointerException e) {}   }A Code fragment a.B Code fragment b.C Code fragment c.D Code fragment d.E Code fragment e.

考题 单选题public class Test {  public static void aMethod() throws Exception {  try {  throw new Exception(); } finally {  System.out.println(“finally”);  }  }  public static void main(String args[]) {  try {  aMethod();  } catch (Exception e) {  System.out.println(“exception”);  }  System.out.println(“finished”);  }  }  What is the result?()A  finallyB  exception finishedC  finally exception finishedD  Compilation fails.

考题 单选题public class Test {  public int aMethod() {  static int i = 0;  i++;  return i;  }  public static void main (String args[]) {  Test test = new Test();  test.aMethod();  int j = test.aMethod();  System.out.println(j);  }  }  What is the result?()A  0B  1C  2D  Compilation fails.

考题 单选题执行以下代码后,下面哪些描述是正确的() public  class  Student{  private String name = “Jema”;  public void setName(String name){  this.name = name;  }  public String getName(){  return this.name;  }  public static void main(String[] args){  Student s;  System.out.println(s.getName()); } }A 输出nullB 第10行编译报错C 第11行编译报错D 输出Jema

考题 单选题下列代码的编译或执行结果是(  )。 public class MyVal{ public static void main(String args[]){ MyVal m = new MyVal(); m.aMethod(); } public void aMethod(){ boolean b[] = new Boolean[5]; System.out.println(b[0]); } }A 1B nullC 0D 编译错误

考题 单选题执行以下代码,输出结果的结果是? () public class Test{  public String[] ss = new String[5];    public static void main(String[] args){      System.out.println(ss[1]);  } }A  nullB  -1C  编译时出错D  运行时报错