现有如下代码, 请分两行写出其运行结果。 class People(object): def __init__(self): print("__init__") def __new__(cls, *args, **kwargs): print("__new__") return object.__new__(cls, *args, **kwargs) People() 知识点:类的定义和使用
现有如下代码, 请分两行写出其运行结果。 class People(object): def __init__(self): print("__init__") def __new__(cls, *args, **kwargs): print("__new__") return object.__new__(cls, *args, **kwargs) People() 知识点:类的定义和使用
参考答案和解析
B
相关考题:
若有如下程序:public class Test {public static void main (String[] args) {int x=20;if (x>10) System.out.print(x-=5);if (x>5) System.out.print(x--);}}则程序运行后的输出结果是【 】。
阅读下列代码 public class Test 2005{ public static void main(String args[]){ Strings="Test"; switch(s){ case "Java":System.out.print("Java"); break; case "Language":System.out.print("Language"); break; case "Test":System.out.ptint("Test"); break; } } } 其运行结果是A.JavaB.LanguageC.TestD.编译出错
( 19 )阅读下列代码public class Test2005{public static void main(String args[]){String s= ″ Test ″ ;Switch(s){case ″ Java ″ : System.out.print( ″ Java ″ ) ;break ;case ″ Language ″ : System.out.print( ″ Language ″ ) ;break ;case ″ Test ″ : System.out.print( ″ Test ″ ) ;break ;}}}其运行结果是A ) JavaB ) LanguageC ) TestD )编译出错
现有:classParser(类)extends(继承)Utils{publicstaticvoidmain(String[]args){System.out.print(输出打印)(newParser().getInt("42"));}intgetInt(Stringarg){returnInteger.parseInt(arg);}}classUtils{intgetInt(Stringarg)throwsException{return42;}}结果为:()A.42B.编译失败。C.无输出结果。D.运行时异常被抛出。
现有:classParserextendsUtils{publicstaticvoidmain(String[]args){System.out.print(newParser().getInt(42));}intgetInt(Stringarg){returnInteger.parseInt(arg);}}classUtils{intgetInt(Stringarg)throwsException{return42;}}结果为()A.42B.编译失败。C.无输出结果。D.运行时异常被抛出。
下列代码的执行结果是( )。 public class test3{ public static void main (string args[]){ System.out.print(100%3); System.out.print(","); System.out.println( 100%3.0); } }A.1,1B.1,1.0C.1.0,1D.1.0,1.0
阅读下列代码 public class Test { public static void main(String args[]) { String s = "Test"; switch (s) { case "Java": System.out.print("Java"); break; case "Language": System.out.print("Language"); break; case "Test": System.out.print("Test"); break; } } } 其运行结果是( )。A.JavaB.LanguageC.TestD.编译出错
阅读下列代码 public class Test2005{ public static void main(String args[]){ String s="Test"; switch(s){ case"Java":System.out.print("Java"); break; case"Language":System.out.print("Lan- guage"); break; case"Test":System.out.print("Test"); break; } } } 其运行结果是( )。A.JavaB.LanguageC.TestD.编译时出错
给定以下JAVA代码,这段代码编译运行后输出的结果是( )publicclassTest{publicstaticintaMethod(inti)throwsException{try{returni/10;}catch(Exceptionex){thrownewException("exceptioninaaMothod");}finally{System.out.print("finally");}}publicstaticvoidmain(String[]args){try{aMethod(0);}catch(Exceptionex){System.out.print("exceptioninmain");}System.out.print("finished");}}A、finallyexceptioninmainfinishedB、exceptioninmainfinallyC、finallyfinishedD、finallyexceptioninmainfinished
现有: 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 (String arg) {return 42; } } 结果为() A、 42B、 ExcC、 42ExcD、编译失败
现有: class ThreadExcept implements Runnable { public void run() { throw new RuntimeException("exception "); } public static void main(String [] args) { new Thread(new ThreadExcept()).start(); try { int x = Integer.parseInt(args[0]); Thread.sleep(x); System.out.print("main "); } catch (Exception e) { } } } 和命令行: java ThreadExcept 1000 哪一个是结果?() A、 mainB、 编译失败C、 代码运行,但没有输出D、 main java.lang.RuntimeException: exception
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、编译失败
现有: class Thread2 implements Runnable { void run() { System.out.print("go "); } public static void main(String [] args) { Thread2 t2 = new Thread2(); Thread t = new Thread(t2); t.start(); } } 结果为:()A、 goB、 编译失败C、 代码运行,无输出结果D、 运行时异常被抛出
现有: 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行出现一个错误,编译失败。
现有: class Birds { public static void main (String [] args) { try { throw new Exception () ; } catch (Exception e) { try { throw new Exception () ; } catch (Exception e2) { System.out.print ("inner "); } System. out.print ( "middle" ) ; } System.out.print ("outer") ; } } 结果是()A、 inner outerB、 middle outerC、 inner middle outerD、.编译失败
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 Output { public static void main (String[] args) { int i=5: System.out.print( "4"+i+""); System.out.print (i+5+"7"); System.out.println (i+"8"); } } 结果为:() A、 99722B、 955758C、 4510758D、 459722
单选题现有: 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) { 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; } } 结果为:()A42B编译失败C无输出结果D运行时异常被抛出
单选题现有: class Thread2 implements Runnable { void run() { System.out.print("go "); } public static void main(String [] args) { Thread2 t2 = new Thread2(); Thread t = new Thread(t2); t.start(); } } 结果为:()A goB 编译失败C 代码运行,无输出结果D 运行时异常被抛出
单选题现有 class Beverage { Beverage () { System.out.print ("beverage "); } } class Beer extends Beverage { public static void main{string [] args) { Beer b = new Beer (14) ; } public int Beer(int x) { this () ; System.out.print ("beerl") ; } public Beer() { System.out.print("beer2 "); } } 结果是什么?()Abeerl beverageBbeer2 beverageCbeverage beer2 beerlD编译失败
单选题现有 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 Cat { Cat(int c) { System.out.print("cat" + c + " "); } } class SubCat extends Cat { SubCat(int c) { super(5); System.out.print("cable "); } SubCat() { this(4); } public static void main(String [] args) { SubCat s = new SubCat(); } } 结果为:()Acat5BcableCcable cat5Dcat5 cable
单选题现有: 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行出现一个错误,编译失败。
单选题现有: 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 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(); }}AShapeBCircleCShapeCircleD程序有错误