首页/ 题库 / [单选题]阅读下面代码 class Test im的答案

阅读下面代码 class Test implements Runnable { public int run() { int i=0; while(true) { i++; System.out.println("i="+i); } } } 上述代码的编译结果是

单选题
2022-01-04 11:37
A、程序通过编译,并且run()方法可以正常输出递增的i值
B、程序通过编译,调用run()方法将不显示任何输出
C、程序不能通过编译,因为while的循环控制条件不能为true
D、程序不能通过编译,因为run()方法的返回值类型不是void
查看答案

正确答案
D

试题解析

标签:
感兴趣题目
请阅读下面程序 public class ThreadTest{ public static void main(String args[]) ( Thread t1=new Thread(new Hello()); Thread t2=new Thread(new Hello()); t1.start(); t2.start(); } } class Hello implements Runnable { int i; public void run() { while(true) { System.out.prinfin("Hello"+i++); if(i=5) break; } } } 该程序创建线程使用的方法是
有下列程序: #include<iostream> using namespace Std; class Test { public: Test() {n+=2;} ~Test() {n-=3;} static int getNum(){return n;} private: static int n; }; int Test∷n=1; int main()
有如下程序: #include<iostream> using namespace std; Class Test { public: Test() {n+=2;} ~Test() {n-=3;} static int getNum() {return n;} private: static int n; }; int Test::n=1; int main() { Test*p=new Test;
阅读下面程序 class Test implements Runnable { public static void main(String[] args) { Test t=new Test(); t.start(): } public void run() {} } 下列关于上述程序的叙述正确的是
阅读下面程序 public class Test implements Runnable { public static void main(String[] args) { ______ t.start(); } public void run() { System.out.println("Hello!"); } } 程序中下画线处应填入的正确选项是
阅读下面程序 public class Test implements Runnable{ public static void main(String[]args){ _______________________________________; t. start(); } public void mR(){ System. out. println("Hello!"); }} 在程序下画线处填入正确选项是
阅读下列代码 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; } } } 其运行结果是( )。
阅读下面代码 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; } } } 其运行结果是
阅读卜列代码 public class Test2005{ public static voidmain(Stringargs[]){ 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; } } } 其运行结果是( )。
阅读下列代码 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; } } } 其运行结果是
执行下列代码段之后,变量z的值为______。 Public class Test8 { public static void main(String[] args) { int x=2; int y=3; int z=4; z-....= y-x--; System.out.println(z); }
执行下列代码后,变量z的值为( )。 public class Test { public static void main (String[]) args) { int x=2; int y=3; int z=4; z- =--y-x--; System. out. Println (z); } }
相关题目
给出如下代码: class Test { private int m; public static void fun() { // some code... }如何使成员变量m 被函数fun()直接访问? ( )
阅读下面代码 public class Test implements Runnable { public void run(Thread t) { System.out.println("Running"); } public static void main(String[] args) { Thread tt=new Thread(new Test()); tt.start(); } } 代码运行的结果是
阅读下面程序 public class Test implements Runnable { public static void main(String[] args) { ______ t.start(); } public void run() { System.out.println("Hello!"); } } 程序中下画线处应填入的正确选项是
阅读下面程序 public class Test implements Runnable{ public static void main(String[]args){ _______________________________________; t. start(); } public void mR(){ System. out. println("Hello!"); }} 在程序下画线处填入正确选项是
阅读下列代码: public class Test{ public static void main(String args[])[ System. out.println(89>>1 ); } }
下列代码中,将引起一个编译错误的行是( )。 1)public class Test{ 2)int m,n; 3)public Test{} 4)public Test(int a){m=a;) 5)public static void main(String args[]){ 6)Test tl,t2; 7)int j,k; 8)j=0;k=0; 9)tl=new Test; 10)t2=new Test(j,k); 11)} 12)}
阅读下列程序:
Public class Test implements Runnable{
Private int x=0l
Private int y=0;
boolean flag=true;
Public static void main(string[]args){
Test r=new Test();
Thead tl=new Thead(r);
Thead t2=new Thead(r);
tl.start();
t2.start();
}
Public void run(){
While(flag){
x++;
y++;
system.out.println("("+x-","+y+")");
if(x>=10)
flag=false;
}
}
}
下列对程序运行结果描述的选项中,正确的是(  )。
下列代码中,将引起一个编译错误的行是(  )。
1)public class Test{
2)int m,n;
3)public Test(){}
4)public Test(int a){m=a;)
5)public static void main(String args[]){
6)Test tl,t2;
7)int j,k;
8)j=0;k=0;
9)tl=new Test();
10)t2=new Test(j,k);
11)}
12)}
阅读下列代码: public class Test{ public static void main(String args[])[ System. out.println(89>>1 ); } }
下列代码执行结果为 ( )public class Test{ public static void main(String args[]){ float p=0f; int q=3; System.out.println(++p)*(q--)); }}
阅读下面代码 public class Test implements Runnable { public void run(Thread t) { System.out.println("Running"); } public static void main(String[] args) { Thread tt=new Thread(new Test()); tt.start(); } } 代码运行的结果是
给出下列代码,如何使成员变量m被方法fun( )直接访问? class Test{ private int m; public static void fun( ){ … } }
给出下列代码,如何使成员变量m被方法fun()直接访问?class Test { private int m; public static void fun( ) { ... }}
阅读下列程序: Public class Test implements Runnable{ Private int x=0l Private int y=0; boolean flag=true; Public static void main(string[]args){ Test r=new Test; Thead tl=new Thead(r); Thead t2=new Thead(r); tl.start; t2.start; } Public void run{ While(flag){ x++; y++; system.out.println("("+x-","+y+")"); if(x>=10) flag=false; } } } 下列对程序运行结果描述的选项中,正确的是( )。
阅读下面程序 public class Test implements Runnable { private int x=0; private int y=0; boolean flag=true; public static void main(String[]args) { Test r=new Test(); Thread t1=new Thread(r); Thread t2=new Thread(r); t1.start(); t2.start(); } public void run() { while(flag) { x++;y++; System.out.println("("+x+","+y+")"); if(x >=10) flag=false; } } } 下列对程序运行结果描述的选项中,正确的是
阅读下面代码 class Test implements Runnable { public int run() { int i=0; while(true) { i++; System.out.println("i="+i); } } } 上述代码的编译结果是
有如下类定义: class Test { private int x; public int y; public void setX (int m) {x=m;} public int getX( ) {return x;} }现用Test t=new Text();生成一个对象t,则如下语句中,错误的是( )。
阅读下面程序 public class Test2 { public static void main(String[] args) { int a=10,b=4.c=20,d=6; System.out.println(a++*b+c*--d); } } 程序运行的结果是
给定java代码如下所示,在A处新增下列()方法,是对cal方法的重载。public class Test {  public void cal(int x, int y, int z) { } //A } 
阅读下面程序 public cmass ThreadTest { public static void main(String args[]) { Thread t1=new Thread(new Hello()); Thread t2=new Thread(new Hello()); t1.start(); t2.start(); } } class Hello implements Runnable { int i; public void run() { while(true) { System.out.println("Hello"+i++); it(i==5) break; } } } 此程序创建线程所使用的方法是
广告位招租WX:84302438

免费的网站请分享给朋友吧