void waitForSignal() {  Object obj = new Object();  synchronized (Thread.currentThread()) {  obj.wait();  obj.notify();  }  }  Which is true?() A、 This code may throw an InterruptedException.B、 This code may throw an IllegalStateException.C、 This code ma

题目

void waitForSignal() {  Object obj = new Object();  synchronized (Thread.currentThread()) {  obj.wait();  obj.notify();  }  }  Which is true?() 

  • A、 This code may throw an InterruptedException.
  • B、 This code may throw an IllegalStateException.
  • C、 This code may throw a TimeoutException after ten minutes.
  • D、 This code will not compile unless “obj.wait()” is replaced with “((Thread) obj).wait()”.
  • E、 Reversing the order of obj.wait() and obj.notify() may cause this method to complete normally.
  • F、 A call to notify() or notifyAll() from another thread may cause this method to complete normally.

相似考题
更多“void waitForSignal() ”相关问题
  • 第1题:

    6:写内存拷贝函数 原型给出 void*mymemcpy(void*dest,void*src,int count)


    正确答案:
     

  • 第2题:

    下面的程序各自独立,请问执行下面的四个TestMemory 函数各有什么样的结果?

    ①void GetMemory(char * p)

    {

    p = (char * )malloc(100);

    }

    void TestMemory (void)

    {

    char *str = NULL;

    GetMemory (str);

    strcpy(str, "hello world");

    prinff(str);

    }

    ② char * GetMemory (void)

    {

    char p[ ] = "hello world";

    return p;

    }

    void TestMemory (void)

    {

    char * str = NULL;

    str = GetMemory( );

    printf(str);

    }

    ③void GetMemory(char * * p, int num)

    {

    * p = (char * )malloc(num);

    }

    void TestMemory (void)

    {

    char * str = NULL;

    GetMemory(&str, 100);

    strcpy( str, "hello" );

    printf(sir);

    }

    ④void TestMemory (void)

    {

    char *str = (char * )malloe(100);

    strepy (str, "hello" );

    free ( str );

    if(str ! = NULL)

    {

    strepy( str, "world" );

    printf(str);

    }

    }


    正确答案:程序1程序崩溃。因为GetMemory并不能传递动态内存TestMemory函数中的str一直都是 NULL。strcpy(str “hello world”);将使程序崩溃。 程序2可能是乱码。因为GetMemory返回的是指向“栈内存”的指针该指针的地址不是 NULL但其原来的内容已经被清除新内容不可知。 程序3能够输出hello但是会发生内存泄漏。 程序4篡改动态内存区的内容后果难以预料非常危险。因为free(str);之后str成为野指针if(str!=NULL)语句不起作用。
    程序1程序崩溃。因为GetMemory并不能传递动态内存,TestMemory函数中的str一直都是 NULL。strcpy(str, “hello world”);将使程序崩溃。 程序2可能是乱码。因为GetMemory返回的是指向“栈内存”的指针,该指针的地址不是 NULL,但其原来的内容已经被清除,新内容不可知。 程序3能够输出hello,但是会发生内存泄漏。 程序4篡改动态内存区的内容,后果难以预料,非常危险。因为free(str);之后,str成为野指针,if(str!=NULL)语句不起作用。

  • 第3题:

    下面正确的函数定义是( )。

    A.Fun()

    B.void fun

    C.void fun()

    D.void fun(){}


    正确答案:D
    解析:见函数定义的格式。

  • 第4题:

    interface Data { public void load(); }  abstract class Info { public abstract void load(); }  Which class correctly uses the Data interface and Info class?() 

    • A、 public class Employee extends Info implements Data { public void load() { /*do something*/ } }
    • B、 public class Employee implements Info extends Data { public void load() { /*do something*/ } }
    • C、 public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }
    • D、 public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }
    • E、 public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }
    • F、 public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }

    正确答案:A

  • 第5题:

    哪二种声明防止方法覆盖?()

    • A、final void methoda() {}
    • B、void final methoda() {}
    • C、static void methoda() {}
    • D、static final void methoda() {}
    • E、final abstract void methoda() {}

    正确答案:A,D

  • 第6题:

    作为类中新线程的开始点,线程的执行是从()方法开始的。

    • A、public void start()
    • B、public void run()
    • C、public void int()
    • D、public static void main(Stringargs[])

    正确答案:A

  • 第7题:

    Which method must be defined by a class implementing the java.lang.Runnable interface? () 

    • A、 void run()
    • B、 public void run()
    • C、 public void start()
    • D、 void run(int priority)
    • E、 public void run(int priority)
    • F、 public void start(int priority)

    正确答案:B

  • 第8题:

    单选题
    Which method must be defined by a class implementing the java.lang.Runnable interface? ()
    A

     void run()

    B

     public void run()

    C

     public void start()

    D

     void run(int priority)

    E

     public void run(int priority)

    F

     public void start(int priority)


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

  • 第9题:

    单选题
    void waitForSignal() {  Object obj = new Object();  synchronized (Thread.currentThread()) {  obj.wait();  obj.notify();  }  }  Which is true?()
    A

     This code may throw an InterruptedException.

    B

     This code may throw an IllegalStateException.

    C

     This code may throw a TimeoutException after ten minutes.

    D

     This code will not compile unless “obj.wait()” is replaced with “((Thread) obj).wait()”.

    E

     Reversing the order of obj.wait() and obj.notify() may cause this method to complete normally.

    F

     A call to notify() or notifyAll() from another thread may cause this method to complete normally.


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

  • 第10题:

    多选题
    下面哪些方法禁止子类重定义该方法()
    A

    protected void m(){}

    B

    final void m(){}

    C

    abstractfinal void m (){}

    D

    staticfinal void m(){}


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

  • 第11题:

    多选题
    Which two code fragments will execute the method doStuff() in a separate thread?()
    A

    new Thread() { public void run() { doStuff(); } }

    B

    new Thread() { public void start() { doStuff(); } }

    C

    new Thread() { public void start() { doStuff(); } } .run();

    D

    new Thread() { public void run() { doStuff(); } } .start();

    E

    new Thread(new Runnable() { public void run() { doStuff(); } } ).run();

    F

    new Thread(new Runnable() { public void run() { doStuff(); } }).start();


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

  • 第12题:

    多选题
    Given: Which four code fragments, inserted independently at line 7, will compile?()
    A

    public void m1() { }

    B

    protected void m1() { }

    C

    private void m1() { }

    D

    void m2() { }

    E

    public void m2() { }

    F

    protected void m2() { }


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

  • 第13题:

    请写出下面的输出:

    class B

    {

    public:

    virtual void Print(void)

    {

    printf(“B::Print\n”);

    }

    virtual void Reprint(void)

    {

    printf(“B:Reprint\n”);

    }

    void Algo(void)

    {

    Print();

    Reprint();

    }

    };

    class D : public B

    {

    public:

    virtual void Print(void)

    {

    printf(“D::Print\n”);

    }

    };

    void main()

    {

    B *p = new D();

    p->Print();

    p->Algo();

    }


    正确答案:
     

  • 第14题:

    下面的说明中,正确的函数定义是( )。

    A.void fun(void)

    B.void fun(void){}

    C.fun(int s){}

    D.fun(int s){return s+1;}


    正确答案:D

  • 第15题:

    下列方法定义中,()是抽象方法。 

    • A、 static void func(){  }
    • B、 virtual void func(){  }
    • C、 abstract void func(){  }
    • D、 overridel void func(){  }

    正确答案:C

  • 第16题:

    Which two declarations prevent the overriding of a method? ()

    • A、 Final void methoda(){}
    • B、 Void final methoda(){}
    • C、 Static void methoda(){}
    • D、 Static final void methoda(){}
    • E、 Final abstract void methoda(){}

    正确答案:A,D

  • 第17题:

    可以限制一个方法重载的声明语句有()。

    • A、final void methoda(){}
    • B、void final methoda(){}
    • C、static final void methoda(){}
    • D、static void methoda(){}
    • E、final abstract void methoda(){}

    正确答案:A,C

  • 第18题:

    下面那一个函数是线程的入口函数? ()

    • A、private void run()
    • B、public void run()
    • C、public void start()
    • D、public void begin()

    正确答案:B

  • 第19题:

    下面哪些方法禁止子类重定义该方法()

    • A、protected void m(){}
    • B、final void m(){}
    • C、abstractfinal void m (){}
    • D、staticfinal void m(){}

    正确答案:B,D

  • 第20题:

    单选题
    interface Data { public void load(); }  abstract class Info { public abstract void load(); }  Which class correctly uses the Data interface and Info class?()
    A

     public class Employee extends Info implements Data { public void load() { /*do something*/ } }

    B

     public class Employee implements Info extends Data { public void load() { /*do something*/ } }

    C

     public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }

    D

     public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }

    E

     public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }

    F

     public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }


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

  • 第21题:

    多选题
    Which two code fragments will execute the method doStuff() in a separate thread?()
    A

    new Thread() {public void run() { doStuff(); }};

    B

    new Thread() {public void start() { doStuff(); }};

    C

    new Thread() {public void start() { doStuff(); }}.run();

    D

    new Thread() {public void run() { doStuff(); }}.start();

    E

    new Thread(new Runnable() {public void run() { doStuff(); }}).start();


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

  • 第22题:

    多选题
    哪二种声明防止方法覆盖?()
    A

    final void methoda() {}

    B

    void final methoda() {}

    C

    static void methoda() {}

    D

    static final void methoda() {}

    E

    final abstract void methoda() {}


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

  • 第23题:

    多选题
    可以限制一个方法重载的声明语句有()。
    A

    final void methoda(){}

    B

    void final methoda(){}

    C

    static final void methoda(){}

    D

    static void methoda(){}

    E

    final abstract void methoda(){}


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