更多“public class Test2 { int x = 50; static int y =200 ; public static void method() { System.out.printl…”相关的问题
第1题
下面程序代码输出结果是 public class Test{ int x,y; Test(int x,int y ){ this.x = x; this.y = y; } public static void main(String args[]){ Test p1,p2; p1 = new Test(3,3); p2 = new Test(4,4); System.out.println(p1.x+p2.x); } }
点击查看答案
第2题
以下程序段输出的结果是( )。 int i=1; int b,c; int a[]=new int[3]; b=a[i]; c=b+i; System.out.println(c);
点击查看答案
第3题
(2)请说出A类中 System.out.println 的输出结果。 class B { int x = 100,y = 200; public void setX(int x) { x = x; } public void setY(int y) { this.y = y; } public int getXYSum() { return x+y; } } public class A { public static void main(String args[]) { B b = new B(); b.setX(-100); b.setY(-200); System.out.println("sum="+b.getXYSum()); } }
点击查看答案
第4题
下列程序中( )【代码】是错误的。 public class TestValue { int x = 100; 【代码1】 static long y = 200; 【代码2】 public void f() { y = 300; 【代码3】 } public static void g() { x = -23; 【代码4】 } }
A、【代码1】
B、【代码2】
C、【代码3】
D、【代码4】
点击查看答案
第5题
下列函数定义中,第4条语句是_________。 1 void Test() 2 { 3 int i=100; 4 object s=i; 5 s+=200; 6 }
点击查看答案
第6题
下面代码的输出结果是(). x = 12.34 print(type(x))
A、<class'complex'>
B、 <class 'int'>
C、 <class'float'>
D、 <class 'bool'>
点击查看答案
第7题
下面程序运行的结果是: public struct myPoint { public int X, Y; public myPoint(int x, int y) { X = x; Y = y; } public myPoint(int x) : this(x, default(int)) { X = x; } public void show() { Console.Write("x={0},y={1}", X, Y); } } class testA { static void Main() { myPoint p1 = new myPoint(2); myPoint p2 = new myPoint(1, 2); p1 = p2; p1.Y = 10; p1.show(); p2.show(); } }
点击查看答案
第8题
class Test { public static void main(String[] args) { int a = 3; int b = 6; System.out.print(a==b); System.out.print(a<b); system.out.print(a!="b);" system.out.print(a> =b); } }
A、false false true false
B、false false true true
C、false true true false
D、true false false true
点击查看答案
第9题
下列程序运行的结果是 _____。 public class function { public static void main(String[] args) { System.out.println(fun(3)); } static int fun(int n) { if(n>2) { return (fun(n-1)+fun(n-2)); }else { return 2; } } }
点击查看答案