• 2022-06-17
    下列哪个方法可用于创建一个可运行的类()
    A: public class X implements Runnable{public void run() {……}}
    B: public class X extends Thread{public void run() {……}}
    C: public class X extends Thread{public int run() {……}}
    D: public class X implements Runnable{protected void run() {……}}
  • A,B

    举一反三

    内容

    • 0

      public class Parent{     public void change(int x){} }  public class Child extends Parent{     //覆盖父类change方法  }  下列哪个声明是正确的覆盖了父类的change方法?() A:  protected void change(int x){} B:  public void change(int x, int y){} C:  public void change(String s){} D:  public void change(int x){}

    • 1

      interface A{ void x(); } class B implements A{ public void x(){} public void y(){} } class C extends B{ public void x(){System.out.println("C");} } public class Test{ public static void main(String args[]){ B b=new B(); B c=new C(); b.x(); c.y(); } } A: 程序运行错误 B: 程序没有输出结果 C: 程序输出C。 D: class B implements A 编译错误 E: c.y();编译错误

    • 2

      给定代码如下: public abstract interface Frobnicate { public void twiddle(String s); } 以下哪个类是正确的?(). A: public abstract class Frob implements Frobnicate { public abstract void twiddle(String s) { } } B: public abstract class Frob implements Frobnicate { } C: public class Frob extends Frobnicate { public void twiddle(Integer i) { } } D: public class Frob implements Frobnicate { public void twiddle(Integer i) { } }

    • 3

      下列程序运行结果是( ) public class Demo { public static void main(String[] args) { Demo demo = new Demo(); demo.show(new Car() { public void run() { System.out.println("demo run"); } }); } public void show(Car c) { c.run(); } }abstract class Car { public void run() { System.out.println("car run..."); } }

    • 4

      下列程序创建了一个线程并运行,请在下画线处填入正确代码。 public class Try extends Thread public static void main(String args[]) Thread t=new Try(); ______; public void run() System.out.printin("Try!");