单选题What is the result?()AThe output is X = 6 y = 0BThe output is x = 7 y = 0CThe output is x = 6 y = -1DThe output is x = 7 y = -1ECompilation will fail.

题目
单选题
What is the result?()
A

 The output is X = 6 y = 0

B

 The output is x = 7 y = 0

C

 The output is x = 6 y = -1

D

 The output is x = 7 y = -1

E

 Compilation will fail.


相似考题
更多“单选题What is the result?()A  The output is X = 6 y = 0B  The output is x = 7 y = 0C  The output is x = 6 y = -1D  The output is x = 7 y = -1E  Compilation will fail.”相关问题
  • 第1题:

    intx=1,y=6;while(y--){x++;}System.out.println(x=”+x+y=”+y);Whatistheresult?()

    A.x=6y=0

    B.x=7y=0

    C.x=6y=-1

    D.x=7y=-1

    E.Compilationfails.


    参考答案:E
    A‘while’statementcanonlyevaluateaBooleanexpression.Theexpressionwhile(y--)returnsanintratherthanaBoolean.Therefore,thecorrectanswerisE.

  • 第2题:

    设以下变量均为int类型,则值不等于7的表达式是( )

    A.(x=y=6,x+y,x+1)
    B.(x=y=6,x+y,y+1)
    C.(x=6,x+1,y=6,x+y)
    D.(y=6,y+1,x=y,x+1)

    答案:C
    解析:

  • 第3题:

    设以下变量都是int类型,则值不等于7的表达式是()。

    • A、x=y=6,x+y,x+1
    • B、x=y=6,x+y,y+1
    • C、x=6,x+1,y=6,x+y
    • D、y=6,y+1,x=y,x+1

    正确答案:C

  • 第4题:

    1. public class X implements Runnable(  2. private int x;  3. private int y;  4.    5. public static void main(String[]args)  6. X that = new X();  7. (new Thread(that)).start();  8. (new Thread(that)).start();  9. )  10.    11. public void run()  (  12. for (;;)  (  13. x++; 14. y++;  15. System.out.printIn(“x=” + x + “, y = ” + y);  16.     ) 17. ) What is the result?()

    • A、 Errors at lines 7 and 8 cause compilation to fail.
    • B、 The program prints pairs of values for x and y that might not always be the same on the same line (for example, “x=2, y=1”).
    • C、 The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by “x=1, y=1”).
    • D、 The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears only for once (for example, “x=1, y=1” followed by “x=2, y=2”).

    正确答案:D

  • 第5题:

    public class X implements Runnable (   private int x;   private int y;    public static void main(String args) (   X that = new X();   (new Thread(that)) . start( );   (new Thread(that)) . start( );   )    public synchronized void run( ) (    for (;;) (    x++;    y++;    System.out.printIn(“x = “ + x + “, y = “ + y);    )   )    )   What is the result?()

    • A、 An error at line 11 causes compilation to fail.
    • B、 Errors at lines 7 and 8 cause compilation to fail.
    • C、 The program prints pairs of values for x and y that might not always be the same on the same line  (for example, “x=2, y=1”)
    • D、 The program prints pairs of values for x and y that are always the same on the same line (forexample, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by  “x=1, y=1”)
    • E、 The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by  “x=2s, y=2”)

    正确答案:E

  • 第6题:

    public class IfTest (  public static void main(string[]args) {  int x = 3;  int y = 1;  if (x = y)  system.out.printIn(“Not equal”);  else  system.out.printIn(“Equal”);  }  )   What is the result?()      

    • A、 The output is “Equal”
    • B、 The output in “Not Equal”
    • C、 An error at line 5 causes compilation to fall.
    • D、 The program executes but does not print a message.

    正确答案:C

  • 第7题:

    int x = 1, y =6;  while (y--) {  x++;  }  System.out.println(“x =” + x + “y =” +y); What is the result?()  

    • A、 x = 6 y = 0
    • B、 x = 7 y = 0
    • C、 x = 6 y = -1
    • D、 x = 7 y = -1
    • E、 Compilation fails.

    正确答案:E

  • 第8题:

    单选题
    int x = 3;  int y = 1;  if (x = y) {  System.out.println(“x = “ + x);  }  What is the result? ()
    A

    x=1

    B

    x=3

    C

    Compilation fails.

    D

    The code runs with no output. 

    E

    An exception is thrown at runtime.


    正确答案: C
    解析: 暂无解析

  • 第9题:

    单选题
    int x = 1, y =6;  while (y--) {  x++;  }  System.out.println(“x =” + x + “y =” +y); What is the result?()
    A

     x = 6 y = 0

    B

     x = 7 y = 0

    C

     x = 6 y = -1

    D

     x = 7 y = -1

    E

     Compilation fails.


    正确答案: E
    解析: A ‘while’ statement can only evaluate a Boolean expression. The expression while(y--) returns an int rather than a Boolean. Therefore, the correct answer is E. 

  • 第10题:

    单选题
    如果输入的数据是2,3,4,则下面程序的输出应为() PROGRAM SAM(INPUT,OUTPUT); VAR i,x,y:integer; BEGIN FOR i:=1 TO 3 DO BEGIN Read(x); y:=sqr(x)END; Writeln(‘x=’,x,‘y=’,y)END.
    A

    x=2 y=4 x=3 y=9 x=4 y=16

    B

    x=4 y=16 x=4 y=16 x=4 y=16

    C

    x=4 y=16

    D

    x=2 y=4 x=2 y=4 x=2 y=4


    正确答案: D
    解析: 暂无解析

  • 第11题:

    单选题
    int x=0;  int y 10;  do {  y--;  ++x;  } while (x < 5);  System.out.print(x + “,“ + y);  What is the result?()
    A

     5,6

    B

     5,5

    C

     6,5

    D

     6,6


    正确答案: B
    解析: 暂无解析

  • 第12题:

    单选题
    设以下变量都是int类型,则值不等于7的表达式是()。
    A

    x=y=6,x+y,x+1

    B

    x=y=6,x+y,y+1

    C

    x=6,x+1,y=6,x+y

    D

    y=6,y+1,x=y,x+1


    正确答案: B
    解析: 暂无解析

  • 第13题:

    阅读以下C++代码,填充(1)~(5)的空缺,将解答填入答题纸的对应栏内。 【说明】在下面程序横线处填上适当的字句,使其输出结果为:x=5x=6y=7x=8z=9【程序】#include<iostream.h>class X1{int x;(1):X1(int xx=0){x=xx;}(2)void Output()(cout<<"x="<<x<<end;}};(3)Y1:public X1{int y;public:Y1(int xx=0,int yy=0):X1(xx){y=yy;}(2)void Output(){(4)Output();cout<<"y="<<y<<end1;}};class Z1:pubtic X1{int z:(5):Z1(int xx=0,int zz=0):X1(xx){z=zz;}②void Output(){X1::Output();cout<<"z="<<z<<end1;}};void main(){X1 a(5);Y1 b(6,7);Z1 c(8,9);X1*p[3]={&a,&b,&c};For(int i=0;i<3;i++){p[i]-->Output();cout<<end1;}}


    答案:
    解析:
    (1)public
    (2)virtual
    (3)class
    (4)X1::
    (5)public
    【解析】

    通过对比三个类的定义就可以发现,在类X1和Z1的定义中缺少类的成员属性声明,而类一般将成员变量声明为公有的、私有的或受保护的三种类型中的一种,在类的定义中,我们一般将类的构造函数放在公有的属性下面,在题目中只能选择公有的属性了,因此,第1空和第5空中应该填“public”。对三个类的定义进行仔细观察后,我们同样可以发现,每个类中都定义了一个同名函数Output(),而且在后两个类的函数体中调用了函数Output(),由此,我们应该想到虚函数。虚函数的作用是允许在派生类中重新定义与基类同名的函数,并且可以通过基类指针或引用来访问基类和派生类中的同名函数。因此,第2空应该填“virtual”。第3空就简单了,考查类的定义,应该填类的标识符“class”。从程序中我们可以看到,类Y1和Z1都以公有的方式继承类X1。从输出的结果来分析,类Y1和Z1都输出了两个数,但单从类Z1的函数来看,只能输出一个变量的值z,因此,可以发现在类Z1中应该和类Y1一样,都调用了类X1的函数Output(),因此,第4空的答案为“X1::”。

  • 第14题:

    如果输入的数据是2,3,4,则下面程序的输出应为() PROGRAM SAM(INPUT,OUTPUT); VAR i,x,y:integer; BEGIN FOR i:=1 TO 3 DO BEGIN Read(x); y:=sqr(x)END; Writeln(‘x=’,x,‘y=’,y)END.

    • A、x=2 y=4 x=3 y=9 x=4 y=16
    • B、x=4 y=16 x=4 y=16 x=4 y=16
    • C、x=4 y=16
    • D、x=2 y=4 x=2 y=4 x=2 y=4

    正确答案:C

  • 第15题:

    int x=0;  int y 10;  do {  y--;  ++x;  } while (x < 5);  System.out.print(x + “,“ + y);  What is the result?() 

    • A、 5,6
    • B、 5,5
    • C、 6,5
    • D、 6,6

    正确答案:B

  • 第16题:

    public class WhileFoo {  public static void main (String []args)   {  int x= 1, y = 6;  while (y--)  {x--;}  system.out.printIn(“x=” + x “y =” + y);  }  }   What is the result?()  

    • A、 The output is x = 6 y = 0
    • B、 The output is x = 7 y = 0
    • C、 The output is x = 6 y = -1
    • D、 The output is x = 7 y = -1
    • E、 Compilation will fail.

    正确答案:E

  • 第17题:

    设以下变量均为int类型,则值不等于7的表达式是()。

    • A、(x=y=6,x+y,x+1)
    • B、(x=y=6,x+y,y+1)
    • C、(x=6,x+1,y=6,x+y)
    • D、(y=6,y+1,x=y,x+1)

    正确答案:C

  • 第18题:

    public class IfTest (   public static void main(stringargs) {   int x = 3;  int y = 1;   if (x = y)   system.out.printIn(“Not equal”);   else   system.out.printIn(“Equal”);   }   )   What is the result?()

    • A、 The output is “Equal”
    • B、 The output in “Not Equal”
    • C、 An error at line 5 causes compilation to fall.
    • D、 The program executes but does not print a message.

    正确答案:C

  • 第19题:

    int x = 3;  int y = 1;  if (x = y) {  System.out.println(“x = “ + x);  }  What is the result? ()

    • A、x=1
    • B、x=3
    • C、Compilation&ensp;fails.
    • D、The&ensp;code&ensp;runs&ensp;with&ensp;no&ensp;output.&ensp;
    • E、An&ensp;exception&ensp;is&ensp;thrown&ensp;at&ensp;runtime.

    正确答案:C

  • 第20题:

    单选题
    public class IfTest (   public static void main(stringargs) {   int x = 3;  int y = 1;   if (x = y)   system.out.printIn(“Not equal”);   else   system.out.printIn(“Equal”);   }   )   What is the result?()
    A

     The output is “Equal”

    B

     The output in “Not Equal”

    C

     An error at line 5 causes compilation to fall.

    D

     The program executes but does not print a message.


    正确答案: C
    解析: 暂无解析

  • 第21题:

    单选题
    public class X implements Runnable(    private int x;   private int y;   public static void main(Stringargs)  X that = new X();   (new Thread(that)).start();  (new Thread(that)).start();  )  public void run() (  for (;;) (  x++;   y++;   System.out.printIn(“x=” + x + “, y = ” + y);   )   )   What is the result?()
    A

     Errors at lines 7 and 8 cause compilation to fail.

    B

     The program prints pairs of values for x and y that might not always be the same on the same line  (for example, “x=2, y=1”).

    C

     The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by  “x=1, y=1”).

    D

     The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears only for once (for example, “x=1, y=1”  followed by “x=2, y=2”).


    正确答案: A
    解析: 暂无解析

  • 第22题:

    单选题
    public class WhileFoo {  public static void main (String []args)   {  int x= 1, y = 6;  while (y--)  {x--;}  system.out.printIn(“x=” + x “y =” + y);  }  }   What is the result?()
    A

     The output is x = 6 y = 0

    B

     The output is x = 7 y = 0

    C

     The output is x = 6 y = -1

    D

     The output is x = 7 y = -1

    E

     Compilation will fail.


    正确答案: E
    解析: 暂无解析

  • 第23题:

    单选题
    public class X implements Runnable (  private int x;  private int y;  public static void main(String [] args) (  X that = new X();  (new Thread(that)) . start( );  (new Thread(that)) . start( );  )  public synchronized void run( ) (  for (;;) (   x++;  y++;  System.out.printIn(“x = “ +  x  + “, y = “ + y);  )  )  )   What is the result?()
    A

     An error at line 11 causes compilation to fail.

    B

     Errors at lines 7 and 8 cause compilation to fail.

    C

     The program prints pairs of values for x and y that might not always be the same on the same line (for example, “x=2, y=1”)

    D

     The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by “x=1, y=1”)

    E

     The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by “x=2s, y=2”)


    正确答案: C
    解析: 暂无解析