单选题package test1;  public class Test1 {  static int x = 42;  }  package test2;  public class Test2 extends test1.Test1 {  public static void main(String[] args) { System.out.println(“x = “ + x);  }  }  What is the result?()A x = 0B x = 42C Compilation fails because of an error in line 2 of class Test2.D Compilation fails because of an error in line 3 of class Test1.E Compilation fails because of an error in line 4 of class Test2.

单选题
package test1;  public class Test1 {  static int x = 42;  }  package test2;  public class Test2 extends test1.Test1 {  public static void main(String[] args) { System.out.println(“x = “ + x);  }  }  What is the result?()
A

 x = 0

B

 x = 42

C

 Compilation fails because of an error in line 2 of class Test2.

D

 Compilation fails because of an error in line 3 of class Test1.

E

 Compilation fails because of an error in line 4 of class Test2.


参考解析

解析: 暂无解析

相关考题:

下面程序段的输出结果为 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.编译不通过

interface A{int x = 0;}class B{int x =1;}class C extends B implements A {public void pX(){System.out.println(x);}public static void main(String[] args) {new C().pX();}}

下面程序段的输出结果为( )。 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.编译不通过

有以下源程序: 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 {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.编译错误

package test1;  public class Test1 {  static int x = 42;  }  package test2;  public class Test2 extends test1.Test1 {  public static void main(String[] args) { System.out.println(“x = “ + x);  }  }  What is the result?() A、 x = 0B、 x = 42C、 Compilation fails because of an error in line 2 of class Test2.D、 Compilation fails because of an error in line 3 of class Test1.E、 Compilation fails because of an error in line 4 of class Test2.

interface DeclareStuff{  public static final int EASY = 3;  void doStuff(int t); }  public class TestDeclare implements DeclareStuff {  public static void main(String [] args) {  int x=5;  new TestDeclare().doStuff(++x);  }  void doStuff(int s) {  s += EASY + ++s;  System.out.println(”s “ + s);  }  }  What is the result?() A、 s 14B、 s 16C、 s 10D、 Compilation fails.E、 An exception is thrown at runtime.

现有:  class Top  {     static int X=l;  public Top()  {  x*=3; }     }  class Middle extends Top  {      public  Middle()    {x+=l;  }  public static void main(String  []  args)  {     Middle m=new Middle();    System.out.println (x);    }     }  结果是什么?()    A、  2B、  3C、  4D、编译失败

class Super {  public int i = 0;  public Super(String text) {  i = 1; }  }  public class Sub extends Super {  public Sub(String text) {  i = 2;  }   public static void main(String args[]) {  Sub sub = new Sub(“Hello”);  System.out.println(sub.i);  }  }  What is the result?()  A、 0B、 1C、 2D、 Compilation fails.

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、编译失败

public class Test {  public static void main(String[] args) {  int x = 0;  assert (x  0) ? “assertion failed” : “assertion passed”;  System.out.println(“Finished”);  }  }  What is the result?()  A、 finishedB、 Compilation fails.C、 An AssertionError is thrown and finished is output.D、 An AssertionError is thrown with the message “assertion failed”.E、 An AssertionError is thrown with the message “assertion passed”.

现有:  class Top  {  static int x=l;  public Top (inty)  {  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、编译失败

public class Test {  private static int[] x;  public static void main(String[] args) {  System.out.println(x[0]);  }  }   What is the result?()   A、 0B、 nullC、 Compilation fails.D、 A NullPointerException is thrown at runtime.E、 An ArrayIndexOutOfBoundsException is thrown at runtime.

public class Test {  public static void main(String[] args) {  int x = 0;  assert (x  0): “assertion failed”;  System.out.println(“finished”);  }  }  What is the result?()  A、 finishedB、 Compilation fails.C、 An AssertionError is thrown.D、 An AssertionError is thrown and finished is output.

public class Starter extends Thread {  private int x= 2;  public static void main(String[] args) throws Exception {  new Starter().makeItSo();  }  public Starter() {  x=5;  start();  }  public void makeItSo() throws Exception {  join();  x=x- 1;  System.out.println(x);  }  public void run() { x *= 2; }  }  What is the output if the main() method is rum?() A、 4B、 5C、 8D、 9E、 Compilation fails.F、 An exception is thrown at runtime.G、 It is impossible to determine for certain.

单选题public class Test {  private static int[] x;  public static void main(String[] args) {  System.out.println(x[0]);  }  }   What is the result?()A 0B nullC Compilation fails.D A NullPointerException is thrown at runtime.E An ArrayIndexOutOfBoundsException is thrown at runtime.

单选题class Super {  public int i = 0;  public Super(String text) {  i = 1; }  }  public class Sub extends Super {  public Sub(String text) {  i = 2;  }   public static void main(String args[]) {  Sub sub = new Sub(“Hello”);  System.out.println(sub.i);  }  }  What is the result?()A 0B 1C 2D Compilation fails.

单选题public class Starter extends Thread {  private int x= 2;  public static void main(String[] args) throws Exception {  new Starter().makeItSo();  }  public Starter() {  x=5;  start();  }  public void makeItSo() throws Exception {  join();  x=x- 1;  System.out.println(x);  }  public void run() { x *= 2; }  }  What is the output if the main() method is rum?()A 4B 5C 8D 9E Compilation fails.F An exception is thrown at runtime.G It is impossible to determine for certain.

单选题package test1;  public class Test1 {  static int x = 42;  }  package test2;  public class Test2 extends test1.Test1 {  public static void main(String[] args) { System.out.println(“x = “ + x);  }  }  What is the result?()A x = 0B x = 42C Compilation fails because of an error in line 2 of class Test2.D Compilation fails because of an error in line 3 of class Test1.E Compilation fails because of an error in line 4 of class Test2.

单选题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 = 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.

单选题现有:  class Top  {  static int x=l;  public Top (inty)  {  x*=3;  }      }  class Middle extends Top {      public Middle()  {x+=1;  )  public  static void main (String  []  args)  {      Middle m = new Middle();      System. out .println (x);      }     }      结果为:()A1B2C3D编译失败

单选题public class Test {  public static void main(String[] args) {  int x = 0;  assert (x  0) ? “assertion failed” : “assertion passed”;  System.out.println(“Finished”);  }  }  What is the result?()A finishedB Compilation fails.C An AssertionError is thrown and finished is output.D An AssertionError is thrown with the message “assertion failed”.E An AssertionError is thrown with the message “assertion passed”.

单选题interface DeclareStuff{  public static final int EASY = 3;  void doStuff(int t); }  public class TestDeclare implements DeclareStuff {  public static void main(String [] args) {  int x=5;  new TestDeclare().doStuff(++x);  }  void doStuff(int s) {  s += EASY + ++s;  System.out.println(”s “ + s);  }  }  What is the result?()A s 14B s 16C s 10D Compilation fails.E 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);  }  }  结果为:()A1B2C3D编译失败

单选题现有:  class Top  {     static int X=l;  public Top()  {  x*=3; }     }  class Middle extends Top  {      public  Middle()    {x+=l;  }  public static void main(String  []  args)  {     Middle m=new Middle();    System.out.println (x);    }     }  结果是什么?()A  2B  3C  4D编译失败

单选题public class Test {  public static void main(String[] args) {  int x = 0;  assert (x  0): “assertion failed”;  System.out.println(“finished”);  }  }  What is the result?()A finishedB Compilation fails.C An AssertionError is thrown.D An AssertionError is thrown and finished is output.