网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
class BitStuff { BitStuff go() { System.out.print("bits "); return this; } } class MoreBits extends BitStuff { MoreBits go() { System.out.print("more "); return this; } public static void main(String [] args) { BitStuff [] bs = {new BitStuff(), new MoreBits()}; for( BitStuff b : bs) b.go(); } } 结果为:()
- A、bits bits
- B、bits more
- C、more more
- D、编译失败
参考答案
更多 “ class BitStuff { BitStuff go() { System.out.print("bits "); return this; } } class MoreBits extends BitStuff { MoreBits go() { System.out.print("more "); return this; } public static void main(String [] args) { BitStuff [] bs = {new BitStuff(), new MoreBits()}; for( BitStuff b : bs) b.go(); } } 结果为:() A、bits bitsB、bits moreC、more moreD、编译失败” 相关考题
考题
classBitStuff{BitStuffgo(){System.out.print(bits);returnthis;}}classMoreBitsextendsBitStuff{MoreBitsgo(){System.out.print(more);returnthis;}publicstaticvoidmain(String[]args){BitStuff[]bs={newBitStuff(),newMoreBits()};for(BitStuffb:bs)b.go();}}结果为:()A.bitsbitsB.bitsmoreC.moremoreD.编译失败
考题
class One { public One() { System.out.print(1); } } class Two extends One { public Two() { System.out.print(2); } } class Three extends Two { public Three() { System.out.print(3); } } public class Numbers{ public static void main( String[] argv) { new Three(); } } What is the result when this code is executed?() A、 1B、 3C、 123D、 321E、 The code rims with no output.
考题
class Flibitz{ public static void main(String[] args){ int grop=7; new Flibitz().go(grop); System.out.print(grop); } void go(int grop){ if(++grop7) grop++; System.out.print(grop); } } 结果为:() A、99B、编译失败C、运行时异常被抛出D、77E、79F、97
考题
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、 foofoofoofoofooB、 foobarfoobarbarC、 foobarfoofoofooD、 foobarfoobarfooE、 barbarbarbarbarF、 foofoofoobarbarG、 foofoofoobarfoo
考题
现有: 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、 运行时异常被抛出。
考题
现有 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、 42ExcB、 ExcC、 42D、编译失败
考题
class Flibitz { public static void main(String [] args) { int grop = 7; new Flibitz().go(grop); System.out.print(grop); } void go(int grop) { if(++grop 〉 7) grop++; System.out.print(grop); } } 结果为:() A、77B、79C、97D、99
考题
class Guy{String greet(){return “hi“}} class Cowboy extends Guy {String greet(){return“howdy”}} class Surfer extends Guy {String greet(){return“dudel”}} class Greetings{ public static void main (string[]args){ Guy[] guy= {new Guy(),new Cowboy(),new Surfer()}; for(Guy 0: guys) System.out.print(g.green()); } } 结果为: A、运行时异常被输出B、第7行出现一个错误,编译失败C、第8行出现一个错误,编译失败D、hi hi hiE、hi hawdy doude
考题
现有: class Bird { void talk() { System.out.print("chirp "); } } class Parrot2 extends Bird { protected void talk() { System.out.print("hello "); public static void main(String [] args) { Bird [] birds = {new Bird(), new Parrot2 () }; for( Bird b : birds) b.talk () ; } } 结果是什么 ?() A、 chirp chirpB、 hello helloC、 chirp helloD、编译错误
考题
class Bird { static void talk() { System.out.print("chirp "); } } class Parrot extends Bird { static void talk() { System.out.print("hello "); } public static void main(String [] args) { Bird [] birds = {new Bird(), new Parrot()}; for( Bird b : birds) b.talk(); } } 结果为:() A、chirp chirpB、chirp helloC、hello helloD、编译失败
考题
现有: class Guy {String greet() {return "hi"; } } class Cowboy extends Guy ( String greet() ( return "howdy ¨; ) ) class Surfer extends Guy (String greet() (return "dude! ";)) class Greetings { public static void main (String [] args) { Guy [] guys = ( new Guy(), new Cowboy(), new Surfer() ); for (Guy g: guys) System.out.print (g.greet()}; } } 结果为:() A、 hi howdy dude!B、运行时异常被抛出。C、第7行出现一个错误,编译失败。D、第8行出现一个错误,编译失败。
考题
final class Tree { private static String tree = "tree "; String getTree() { return tree; } } class Elm extends Tree { private static String tree = "elm "; public static void main(String [] args) { new Elm().go(new Tree()); } void go(Tree t) { String s = t.getTree()+Elm.tree+tree+(new Elm().getTree()); System.out.println(s); } } 结果为:() A、elm elm elm elmB、tree elm elm elmC、tree elm tree elmD、编译失败
考题
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、42B、NFExcC、42NFExcD、编译失败
考题
class Passer { static final int x = 5; public static void main(String [] args) { new Passer().go(x); System.out.print(x); } void go(int x) { System.out.print(++x); } } 结果是什么?() A、55B、56C、65D、66
考题
public class X { public static void main(String [] args) { try { badMethod(); System.out.print(“A”); } catch (Exception ex) { System.out.print(“B”); } finally { System.out.print(“C”); } System.out.print(“D”); } public static void badMethod() { throw new RuntimeException(); } } What is the result? () A、 ABB、 BCC、 ABCD、 BCDE、 Compilation fails.
考题
class Base { Base() { System.out.print(“Base”); } } public class Alpha extends Base { public static void main( String[] args ) { new Alpha(); new Base(); } } What is the result?() A、 BaseB、 BaseBaseC、 Compilation fails.D、 The code runs with no output.E、 An exception is thrown at runtime.
考题
public class Threads4 { public static void main (String[] args) { new Threads4().go(); } public void go() { Runnable r = new Runnable() { public void run() { System.out.print(”foo”); } }; Thread t = new Thread(r); t.start(); t.start(); } } What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 The code executes normally and prints „foo”.D、 The code executes normally, but nothing is printed.
考题
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、运行时异常被抛出
考题
单选题class Base { Base() { System.out.print(“Base”); } } public class Alpha extends Base { public static void main( String[] args ) { new Alpha(); new Base(); } } What is the result?()A
BaseB
BaseBaseC
Compilation fails.D
The code runs with no output.E
An exception is thrown at runtime.
考题
单选题class One { public One() { System.out.print(1); } } class Two extends One { public Two() { System.out.print(2); } } class Three extends Two { public Three() { System.out.print(3); } } public class Numbers{ public static void main( String[] argv) { new Three(); } } What is the result when this code is executed?()A
1B
3C
123D
321E
The code rims with no output.
考题
单选题现有: class Tree { private static String tree = "tree "; String getTree () { return tree; } } class Elm extends Tree { private static String tree = "elm "; public static void main (String [] args) { new Elm() .go (new Tree()) ; } } void go (Tree t) { String s = t.getTree () +Elm.tree + tree + (new Elm() .getTree ()) ; System.out.println (s) ;} 结果为:()A
elm elm elm elmB
tree elm elm elmC
tree elm elm treeD
tree elm tree elm
考题
单选题class Flibitz { public static void main(String [] args) { int grop = 7; new Flibitz().go(grop); System.out.print(grop); } void go(int grop) { if(++grop 〉 7) grop++; System.out.print(grop); } } 结果为:()A
77B
79C
97D
99
考题
单选题下列程序的运行结果是( )。class Shape{ public Shape(){ System.out.print("Shape"); }}class Circle extends Shape{ public Circle(){ System.out.print("Circle"); }}public class Test{ public static void main(String[]args){ Shape d=new Circle(); }}A
ShapeB
CircleC
ShapeCircleD
程序有错误
考题
单选题class Passer { static final int x = 5; public static void main(String [] args) { new Passer().go(x); System.out.print(x); } void go(int x) { System.out.print(++x); } } 结果是什么?()A
55B
56C
65D
66
考题
单选题现有 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
42ExcB
ExcC
42D
编译失败
考题
单选题class BitStuff { BitStuff go() { System.out.print("bits "); return this; } } class MoreBits extends BitStuff { MoreBits go() { System.out.print("more "); return this; } public static void main(String [] args) { BitStuff [] bs = {new BitStuff(), new MoreBits()}; for( BitStuff b : bs) b.go(); } } 结果为:()A
bits bitsB
bits moreC
more moreD
编译失败
考题
单选题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
foofoofoofoofooB
foobarfoobarbarC
foobarfoofoofooD
foobarfoobarfooE
barbarbarbarbarF
foofoofoobarbarG
foofoofoobarfoo
热门标签
最新试卷