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

题目内容 (请给出正确答案)
单选题
1.public class Test {  2.public static void main (String args[]) {  3.class Foo {  4.public int i = 3;  5.}  6.Object o = (Object) new Foo();  7.Foo foo = (Foo)o;  8.System.out.printIn(foo. i); 9. }  10.}   What is the result?()
A

 Compilation will fail.

B

 Compilation will succeed and the program will print “3”

C

 Compilation will succeed but the program will throw a ClassCastException at line 6.

D

 Compilation will succeed but the program will throw a ClassCastException at line 7.


参考答案

参考解析
解析: 暂无解析
更多 “单选题1.public class Test {  2.public static void main (String args[]) {  3.class Foo {  4.public int i = 3;  5.}  6.Object o = (Object) new Foo();  7.Foo foo = (Foo)o;  8.System.out.printIn(foo. i); 9. }  10.}   What is the result?()A  Compilation will fail.B  Compilation will succeed and the program will print “3”C  Compilation will succeed but the program will throw a ClassCastException at line 6.D  Compilation will succeed but the program will throw a ClassCastException at line 7.” 相关考题
考题 下列程序的运行结果是【 】。public class Test {public static void main (String args[]) {String s1="hello!";System.out.println (s1.toUpperCase());}}

考题 已知如下类说明: public class Test { private float f = 1.0f; int m = 12; static int n=1; public static void main(String arg[]) { Test t = new Test(); // 程序代码… } } 如下哪个使用是正确的?() A.t.fB.this.nC.Test.mD.Test.n

考题 已知有下列类的说明,则下列哪个语句是正确的?public class Test { private float f=1.0f; int m=12; static int n=1; public static void main(String arg[]) { Test t= new Test(); }}A.t.f;B.this. nC.Test.m;D.Test.f;

考题 下列程序的输出结果是public class fff { void printValue (int m) { do { System.out.println("The value is" +m); } while(--m>10) } public static void main (String arg[]) { int i=10; Test t= new Test(); t. printValue(i); }}A.8B.9C.10D.11

考题 下列程序的输出结果是class Test{public static void main(String args[]){int n=7;n 下列程序的输出结果是 class Test{ public static void main(String args[]){ int n=7; n<<=3; n=nn+1|n+2^n+3; n>>=2; System.out.println(n); } }A.0B.-1C.14D.64

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

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

考题 执行以下代码会输出什么结果?()   public class Test {    StringgetStr(String s){  return s + “hello”;  }  public static void main(String arg[]) {           Test t= new Test();  System.out.println(t.getStr(“LiLei/n”));     } } A、 编译报错B、 LiLei    helloC、 LiLeihelloD、 无任何输出

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

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

考题 Public class test (  Public static void stringReplace (String text)  (  Text = text.replace (‘j’ , ‘i’);  )  public static void bufferReplace (StringBuffer text)  (  text = text.append (“C”)  )   public static void main (String args[]}  (  String textString = new String (“java”);  StringBuffer text BufferString = new StringBuffer (“java”);  stringReplace (textString);  BufferReplace (textBuffer);  System.out.printLn (textString + textBuffer);  )  )   What is the output?()

考题 下面关于Java应用程序中main方法的写法,合法的是()。A、public static void main()B、public static void main(Stringargs[])C、public static int main(String[]arg)D、public void main(Stringarg[])

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

考题 1.public class test (  2.public static void main (String args[])    {  3.int  i = 0xFFFFFFF1;  4.int  j = ~i;  5.    6.}  7.)    What is the decimal value of j at line 5?()  A、 0B、 1C、 14D、 –15E、 An error at line 3 causes compilation to fail.F、 An error at line 4 causes compilation to fail.

考题 Given the following code:    public class Test {  void printValue(int m){  do {  System.out.println("The value is"+m);     }  while( --m  10 )     }  public static void main(String arg[]) {     int i=10;  Test t= new Test();     t.printValue(i);     }     }  Which will be output?()    A、 The value is 8B、 The value is 9C、 The value is 10D、 The value is 11

考题 1.public class Test {  2.public static void main (String args[]) {  3.class Foo {  4.public int i = 3;  5.}  6.Object o = (Object) new Foo();  7.Foo foo = (Foo)o;  8.System.out.printIn(foo. i); 9. }  10.}   What is the result?()  A、 Compilation will fail.B、 Compilation will succeed and the program will print “3”C、 Compilation will succeed but the program will throw a ClassCastException at line 6.D、 Compilation will succeed but the program will throw a ClassCastException at line 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、42B、编译失败C、无输出结果D、运行时异常被抛出

考题 单选题1.public class test (  2.public static void main (String args[])    {  3.int  i = 0xFFFFFFF1;  4.int  j = ~i;  5.    6.}  7.)    What is the decimal value of j at line 5?()A  0B  1C  14D  –15E  An error at line 3 causes compilation to fail.F  An error at line 4 causes compilation to fail.

考题 多选题Which declarations will allow a class to be started as a standalone program?()Apublic void main(String args[])Bpublic void static main(String args[])Cpublic static main(String[] argv)Dfinal public static void main(String [] array)Epublic static void main(String args[])

考题 单选题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[])

考题 单选题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 42B 编译失败C 无输出结果D 运行时异常被抛出

考题 填空题Public class test (    Public static void main (String args) (   System.out.printIn (6^3);   )   )   What is the output? ()

考题 单选题下面关于Java应用程序中main方法的写法,合法的是()。A public static void main()B public static void main(Stringargs[])C public static int main(String[]arg)D public void main(Stringarg[])

考题 填空题Public class test (    Public static void stringReplace (String text) (    Text = text.replace („j„ , „i„);    )      public static void bufferReplace (StringBuffer text) (    text = text.append (“C”)   )      public static void main (String args ){  String textString = new String (“java”);    StringBuffer text BufferString = new StringBuffer (“java”);      stringReplace (textString);    BufferReplace (textBuffer);      System.out.printIn (textString + textBuffer);    }   )   What is the output?()

考题 单选题执行以下代码会输出什么结果?()   public class Test {    StringgetStr(String s){  return s + “hello”;  }  public static void main(String arg[]) {           Test t= new Test();  System.out.println(t.getStr(“LiLei/n”));     } }A  编译报错B  LiLei    helloC  LiLeihelloD  无任何输出

考题 单选题Given the following code:    public class Test {  void printValue(int m){  do {  System.out.println("The value is"+m);     }  while( --m  10 )     }  public static void main(String arg[]) {     int i=10;  Test t= new Test();     t.printValue(i);     }     }  Which will be output?()A  The value is 8B  The value is 9C  The value is 10D  The value is 11

考题 单选题1.public class Test {  2.public static void main (String args[]) {  3.class Foo {  4.public int i = 3;  5.}  6.Object o = (Object) new Foo();  7.Foo foo = (Foo)o;  8.System.out.printIn(foo. i); 9. }  10.}   What is the result?()A  Compilation will fail.B  Compilation will succeed and the program will print “3”C  Compilation will succeed but the program will throw a ClassCastException at line 6.D  Compilation will succeed but the program will throw a ClassCastException at line 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  42B  编译失败。C  无输出结果。D  运行时异常被抛出。