14、下面程序的运行结果是:() class test{ public static void main(String[] args) { String str = "hello zut"; System.out.print(str.charAt(2)); System.out.print(str.length()); System.out.print(str.substring(4)); } }A.e9ozutB.l9o zutC.l8 zutD.e8o zut
14、下面程序的运行结果是:() class test{ public static void main(String[] args) { String str = "hello zut"; System.out.print(str.charAt(2)); System.out.print(str.length()); System.out.print(str.substring(4)); } }
A.e9ozut
B.l9o zut
C.l8 zut
D.e8o zut
参考答案和解析
A 解析:由于类C14实现了Runnable接口,没有继承类Thread,因此需要调用 Thread.currentThread()方法来返回当前线程的引用。在main()方法中,调用了类C14构造方法,其参数就是线程睡眠的时间300毫秒,而Thread类构造方法的另一个参数就是线程的名称t。
相关考题:
若有如下程序: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 {public static void main (String args[]) {String s1="hello!";System.out.println (s1.toUpperCase());}}
阅读下列代码 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 )编译出错
执行下面程序后输出的正确结果是 public class Test{ public static void main(String args[]){ byte x=3,y=4; long r=80L; System.out.print(r/y); System.out.print(","); System.out.print(x/y); } }A.20.0,1B.20.0,1.0C.20,0D.20,1.0
执行下面程序后输出的正确结果是( )。 public class Test{ public static void main(String args[]){ System.out.print(100%3); System.out.print(","); System.out.print(100%0); } }A.1,1B.1,1.0C.1.0, lD.1.0,1.0
阅读下面代码 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.编译出错
下列代码的执行结果是( )。 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 Example{ String str=new String("good"); char[]ch={'a','b','c'}; public static void main(String args[]){ Example ex=new Example(); ex.change(ex.otr,ex.ch); System.out.print(ex.str+"and"); System.out.print(ex.ch); } public void change(String str,char ch[])} str="test ok"; ch[0]≈'g'; } }A.good and abcB.good and gbcC.test ok and abcD.test ok and gbc
阅读下列代码 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.编译时出错
下列代码的执行结果是______。 public class ex55 { public static void main(String args[] ) { String s1=new String("hello"); String s2=new String("hello"); System.out.print (s1==s2); System.out.print (","); System.out.println (s1.equals (s2)); } }A.true, falseB.true, trueC.false, trueD.false, false
执行下面程序后输出的正确结果是 public class Test{ public stoic void main (String args[]){ byte x=3, y=4; long r=80L; System.out.print(r/y); System.out.print(","); System.out.print(x/y); } }A.20.0, 1B.20.0, 1.0C.20,0D.20, 1.0
下列程序运行的结果为:public class Example{String str=new String("good");char[] ch={'a','b','c'};public static void main(String args[]){Example ex=new Example();ex.change(ex.str,ex.ch);System.out.print(ex.str+" and ");Sytem.out.print(ex.ch);}public void change(String str,char ch[]){str="test ok";ch[0]='g';}}A. good and abcB. good and gbcC. test ok and abcD. test ok and gbc
现有: 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、编译失败
static void test() { try { String x=null; System.out.print(x.toString() +“ “); } finally { System.out.print(“finally “); } } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print(”exception “); } } What is the result?() A、 nullB、 finallyC、 null finallyD、 Compilation fails.E、 finally exception
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() {} } What is the result?() A、 ACB、 BDC、 ACDD、 ABCDE、 Compilation fails.
public class TestApp{ public static void main(String[] args){ try{ String myname = null; if(myname.length()2) System.out.print(“1”); }catch(NullPointerException e){ System.out.print(“2”); } } } 上述程序运行后的输出是哪项?() A、 1B、 12C、 21D、 2
public static void test(String str) { int check = 4; if (check = str.length()) { System.out.print(str.charAt(check -= 1) +“, “); } else { System.out.print(str.charAt(0) + “, “); } } and the invocation: test(”four”); test(”tee”); test(”to”); What is the result?() A、 r, t, t,B、 r, e, o,C、 Compilation fails.D、 An exception is thrown at runtime.
单选题现有 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编译失败
单选题public static void test(String str) { int check = 4; if (check = str.length()) { System.out.print(str.charAt(check -= 1) +“, “); } else { System.out.print(str.charAt(0) + “, “); } } and the invocation: test(”four”); test(”tee”); test(”to”); What is the result?()A r, t, t,B r, e, o,C Compilation fails.D An exception is thrown at runtime.
单选题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(); } } 结果为:()Achirp chirpBchirp helloChello helloD编译失败
单选题现有: 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编译错误
单选题public class TestApp{ public static void main(String[] args){ try{ String myname = null; if(myname.length()2) System.out.print(“1”); }catch(NullPointerException e){ System.out.print(“2”); } } } 上述程序运行后的输出是哪项?()A 1B 12C 21D 2
单选题static void test() { try { String x=null; System.out.print(x.toString() +“ “); } finally { System.out.print(“finally “); } } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print(”exception “); } } What is the result?()A nullB finallyC null finallyD Compilation fails.E finally exception
单选题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() {} } What is the result?()A ACB BDC ACDD ABCDE Compilation fails.
单选题下列程序的运行结果是( )。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程序有错误