下面程序运行后的输出结果为() class A{ public int y=6; void showy(){ System.out.println("y="+y); } } class testA{ public static void main(String aaa []){ A a1 = new A(); A b1 = new A(); a1.y++; b1.showy(); } } 输出结果选择:A.y=6B.程序运行出错C.y=8D.y=7

下面程序运行后的输出结果为() class A{ public int y=6; void showy(){ System.out.println("y="+y); } } class testA{ public static void main(String aaa []){ A a1 = new A(); A b1 = new A(); a1.y++; b1.showy(); } } 输出结果选择:

A.y=6

B.程序运行出错

C.y=8

D.y=7


参考答案和解析
B 解析:在main函数中定义了一个structabc类型的数组,同时分别利用{1,2,3}及{4,5,6}对数组中两个元素进行初始化。在该结构体,依次对其中的a,b,c三个变量进行初始化。故s[0].a=1,s[1].b=5,所以本题输出为6。

相关考题:

下列程序段的输出结果是【 】。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 Sun { public static void main(String args[]) { String x="A",y="B",z="C"; for(int m=1;m<=2;m++) { x=y; y=z; z=x; } System.out.println(x+y+z); } }A.ABCB.BCAC.BCBD.CBC

下面程序的输出为( )。 public class Test { public static void main (String args[]) { int x,y; x=1; y=2; System.out.println("The output is"+x+y); } }A.The output is xyB.The output is 3C.The output is 12D.The output is x=1 y=2

执行下面程序段,屏幕上将输出( )。 public class Test { private int x=10,y=20; public Test (int x,int y) { System.out.println (x+this.x); System.out.println (y+y); } public static void main (String[] args) { Testt= new Test(30,50); } }A.无输出B.20 40C.40 100D.40 70

下面程序的输出结果为( )。 public class Test { public static void main (String args[]) { String X="ABCD"; String Y="EFG"; X=X.substring (X.length()-Y.length()); System.out.println(X); } }A.ABCB.BCDC.EFGD.ABCDEFG

执行下面的程序段,输出结果为______。public class Q{public static void main(String argvr)){int anar[]=new int[5];System.out.println(anar[0]);}}

下面程序的输出结果是什么? class C1{ static int j=0; public void method(int a){ j++; } } class Test extends C1{ public int method(){ return j++; } public void result(){ method(j); System.out.println(j+method()); } public static void main(String args[]){ new TeA.0B.1C.2D.3

下面程序段的输出结果为 package test; public class ClassA { int x=20; static int y=6; public static void main(String args[]) { ClassB b=new ClassB(); b.go(10); System.out.println("x="+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }A.x=10B.x=20C.x=6D.编译不通过

下列语句输出结果为( )。 public class test { public static void main (String args[]) { int x=10,y=9; boolean b=true; System.out.println(x<y||!b); } }A.真B.假C.1D.0

阅读下面程序 public class Test3 { public static void main(String[] args) { int x=3,y=4,z=5; String s="xyz": System.out.println(s+x+y+z); } } 程序运行的结果是A.xyz12B.xyz345C.xyzxyzD.12xyz

下面程序片段的执行中,说法正确的是( )。 public class Test { public static void main (String args[]) { byte y=20; int i=y; int x=100; y=x; System.out.println(y); } }A.输出y的值为100B.第4行错误C.输出y的值为20D.第6行错误

下列语句输出结果为( )。 public class test { public static void main(String args[ ]) { int x=10,y=8; boolean b=true; System.out.println(x>0&&x<y||b); } }A.真B.假C.1D.0

执行下面程序,显示的结果为( )。 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

以下程序运行后的输出结果是______。includeinclude usingnamespacestd;classY 以下程序运行后的输出结果是______。include <iostream>include <string>using namespace std;class Y;class X{int x;char *strx;public:X(int a, char *str){x=a;strx=new char[strlen(str)+1]strcpy (strx,str);}void show(Y ob);};class Y{prlvate:int y;char *stry;public:Y(int b,char *str){y=b;stry=new char[strlen(str)+1];strcpy(stry,str);}friend void X::show(Y ob);};void X::show{Y ob){cout<<strx<<",",cout<<ob.stry<<endl;}int main{{X a (10, "stringX");Y b (20, "stringY");a. show (b);renurn 0;}

执行下面程序段的输出结果为( )。 public class Q { public static void main(String argv[]) { int anar[]一new int[5]; System.out.println(anar[0]); } }A.0B.1C.2D.5

下面程序段的输出结果为( )。 package test; public class ClassA { int x=20: static int y=6; public static void main(String args[]) { ClassB b=new ClassB; go(10); System.out.println("x="+b.x); } } class ClassB { int X; void go(int y) { ClassA a=new ClassA; x=a.Y ; } }A.x=10B.x=20C.x=6D.编译不通过

下面程序段的输出结果为 package test; public class A { int x=20; static int y=6; public static void main(String args[]) { Class B b=new Class B(); b.go(10); System.out.println(”x=”+b.x); } } class Class B { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }A.x=10B.x=20C.x=6D.编译不通过

下面程序输出的结果是( )。 include using namespace std; class A{ 下面程序输出的结果是( )。 #include<iostream> using namespace std; class A{ int X; public: A(int x):x(++x){} ~A(){cout<<x;} }; class B:public A{ int y; public: B(int y):A(y),y(y){} ~B(){cout<<y;}; }; void main(){ B b(3); }A.34B.43C.33D.44

有以下源程序: package test; public class ClassA { int x=20; static int y=6; public static void main(String args[]) { ClassB b=new ClassB(); b.go(10); System.out.println("x="+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } } 上述源程序文件的运行结果为( )。A.x=10B.x=20C.x=6D.编译不通过

执行下列程序段之后,输出的结果为______。 public class ex41 { public static void main(string[] args) { int x=15; byte y=1; x>>=y++; System.out.println(x); } }A.3B.7C.14D.10

执行如下语句之后,输出的结果是______。 public class ex36 { public static void main(String[] args) { int x=-6, y=6; x=x+y--; System.out.println (x); } }A.-12B.12C.-1D.0

以下的程序的调试结果为?public class MyAr{public static void main(String argv[]) {MyAr m = new MyAr();m.amethod();}public void amethod(){static int i;System.out.println(i);}} A. 输出结果为 0B. 运行出错C. 输出结果为 nullD. 编译错误

以下的程序的调试结果为public class Scope{int i;public static void main(String argv[]){Scope s = new Scope();s.amethod();}public static void amethod(){System.out.println(i);}} A. 输出结果为:0B. 无输出C. 编译错误D. 输出null

class DemoApp{  public static void main(String[] args){  int x = 5; int y = ++x + x++; S ystem.out.println(“y=”+y+”,x=”+x);  }  }  以上程序运行后的输出结果是哪项?() A、y=10,x=5B、y=11,x=6C、y=12,x=7D、y=11,x=7

class TestA {  public void start() { System.out.println(”TestA”); }  }  public class TestB extends TestA {  public void start() { System.out.println(”TestB”); } public static void main(String[] args) {  ((TestA)new TestB()).start();  }  }  What is the result?() A、 TestAB、 TestBC、 Compilation fails.D、 An exception is thrown at runtime.

class Top {  static int x = 1;  public Top(int y) { x *= 3; }  }  class Middle extends Top {  public Middle() { x += 1; }  public static void main(String [] args) {  Middle m = new Middle();  System.out.println(x);  }  }  结果为:() A、1B、2C、3D、编译失败

现有:      class TestA  {  public void start()  {  System.out.println("TestA");  }     }  public class TestB extends TestA  {  public void start()  {  System.out.println("TestB");  }     public static void main (string[]  args)  (     ((TestA)new TestB()).start();     )     }  运行结果是哪项?()     A、  TeStAB、  TeStBC、编译失败D、运行时抛出异常

单选题现有:      class TestA  {  public void start()  {  System.out.println("TestA");  }     }  public class TestB extends TestA  {  public void start()  {  System.out.println("TestB");  }     public static void main (string[]  args)  (     ((TestA)new TestB()).start();     )     }  运行结果是哪项?()A  TeStAB  TeStBC编译失败D运行时抛出异常