网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
以下代码的输出结果?public class Test{int x=5;public static void main(String argv[]){Test t=new Test();t.x++;change(t);System.out.println(t.x);}static void change(Test m){m.x+=2;}}
A. 7
B. 6
C. 5
D. 8
参考答案
更多 “ 以下代码的输出结果?public class Test{int x=5;public static void main(String argv[]){Test t=new Test();t.x++;change(t);System.out.println(t.x);}static void change(Test m){m.x+=2;}} A. 7B. 6C. 5D. 8 ” 相关考题
考题
下列程序段的输出结果是【 】。public class Test {void printValue(int m) {do {System.out.println("The value is"+m);}while (--m>10);}public static void main (String args[]) {int i=10;Test t= new Test();t.printValue(i);}}
考题
如下程序的输出结果是( )。 public class Test { void printValue(int m) { do { System.out.println("The value is"+m); } while( --m>10) } public static void main(String args[]) { int i=10; Test t=new Test(); t.printValue(i); } }A.The value is 8B.The value is 9C.The value is 10D.The value is 11
考题
请在下划线处填入代码,是程序正常运行并且输出 “ Hello! ”Class Test 【 15 】 {Public static void main (String[] arge){Test t = new Test();t.start();}Public void run(){System.out.println( “ Hello! ” );}
考题
已知如下类说明: 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 { public int aMethod() { satic int i=0; i++; System.out.println(i); } public static void.main(String args[]) { Test test=new Test(); test.aMethod(); }A.编译错误B.0C.1D.运行成功,但不输出
考题
已知有下列类的说明,则下列哪个语句是正确的?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 Test{ public int aMethod(){ static int i=0; i++; System.out.println(i); } public static void main(String args[]){ Test test= new Test(); test. aMethod(); }}A.编译错误B.0C.1D.运行成功,但不输出
考题
下列程序的输出结果是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
考题
执行下面程序,显示的结果为( )。 public class Test { public static void main (String args[]) { Test t=newTest(); System.out.println (Loverload ("2","3")); } int overload (intx,int y) {return x+y;} String overload (String x,Stnng y){return x+y;} }A.2B.3C.5D.23
考题
下列代码中,将引起编译错误的行是______。 (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 t1,t2; (7) int j,k; (8) j=0;k=0; (9) t1=new Test( ); (10) t2=new Test(j,k); (11) 1 (12) }A.第3行B.第5行C.第6行D.第10行
考题
已知有下列类的说明,则下列哪个语句是正确的? ( ) public class Test { private float f=1.0f; int m=2; static int n=1; public static void main(String arg[]) { Test t=new Test(); } }A.t.f;B.this,n;C.Test.m;D.Test.f;
考题
下列代码的执行结果是( )。public class Test{public int aMethod( ){static int i=0;i++;System.out.println(i):}public static void main (String args[]){Trest test=new Test ( );test aMethod( ):}}A.编译错误B.0C.1D.运行成功,但不输出B.C.D.
考题
阅读下面程序 public class Test implements Runnable { public static void main(String[] args) { ______ t.start(); } public void run() { System.out.println("Hello!"); } } 程序中下画线处应填入的正确选项是A.Test t=new Test();B.Thread t=new Thread();C.Thread t=new Thread(new Test());D.Test t=new Thread();
考题
以下代码的输出结果?public class Test{int x=3;public static void main(String argv[]){int x= 012;System.out.println(x);}}
A.12B.012C.10D.3
考题
以下程序的运行结果为:public class Test{public static void main(String argv[ ]){System.out.println("x="+ 5、;}}
A. 5B. x=5C. "x="+5D. "x="5
考题
以下代码的输出结果?public class Test{public static void main(String argv[]){String x="hello";change(x);System.out.println(x);}static void change(String m){m=m+2;}}
A. helloB. hello2C. 编译报错D. 运行报错,不能将串与整数相加
考题
以下程序调试结果为:public class Test {int m=5;public void some(int x) {m=x;}public static void main(String args []) {new Demo().some(7);}}class Demo extends Test {int m=8;public void some(int x) {super.some(x);System.out.println(m);}}A.5B.8C.7D.无任何输出E.编译错误
考题
( 30 )在程序的下划线处应填入的选项是public class Test _________{public static void main(String args[]){Test t = new Test();Thread tt = new Thread(t);tt.start();}public void run(){for(int i=0;i5;i++){system.out.println( " i= " +i);}}}A ) implements RunnableB ) extends ThreadC ) implements ThreadD ) extends Runnable
考题
执行以下代码会输出什么结果?() 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、 无任何输出
考题
编译如下Java程序片断: class test{ int count = 9; public void a(){ int count=10; System.out.println("count 1 =" + count); } public void count(){ System.out.println("count 2 =" + count); } public static void main(String args[]){ test t=new test(); t.a(); t.count(); } } 结果将()。 A、不能通过编译B、输出: count 1 = 10 count 2 = 9C、输出:count 1 = 9 count 2 = 9
考题
public class Test { public int aMethod() { static int i = 0; i++; return i; } public static void main (String args[]) { Test test = new Test(); test.aMethod(); int j = test.aMethod(); System.out.println(j); } } What is the result?() A、 0B、 1C、 2D、 Compilation fails.
考题
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
考题
单选题public class Test { public int aMethod() { static int i = 0; i++; return i; } public static void main (String args[]) { Test test = new Test(); test.aMethod(); int j = test.aMethod(); System.out.println(j); } } What is the result?()A
0B
1C
2D
Compilation fails.
考题
单选题执行以下代码会输出什么结果?() 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
考题
单选题编译如下Java程序片断: class test{ int count = 9; public void a(){ int count=10; System.out.println("count 1 =" + count); } public void count(){ System.out.println("count 2 =" + count); } public static void main(String args[]){ test t=new test(); t.a(); t.count(); } } 结果将()。A
不能通过编译B
输出: count 1 = 10 count 2 = 9C
输出:count 1 = 9 count 2 = 9
考题
单选题编译如下的Java程序片段: Class test{ Int count=9; Public void a(){ Int count=10; System.out,println(“count 1=” + count); } Public void count(){ System.out.println(“count 2 =”+ count); } Public static void main(String args[] ){ Test t=new Test(); t.a(); t.count(); } } 结果是()A
不能通过编译B
输出:count 1 =10 count 2=9C
输出:count 1=9 count 2=9
热门标签
最新试卷