多选题Which three statements are true?()AA final method in class X can be abstract if and only if X is abstract.BA protected method in class X can be overridden by any subclass of X.CA private static method can be called only within other static methods in c

题目
多选题
Which three statements are true?()
A

A final method in class X can be abstract if and only if X is abstract.

B

A protected method in class X can be overridden by any subclass of X.

C

A private static method can be called only within other static methods in class X.

D

A non-static public final method in class X can be overridden in any subclass of X.

E

A public static method in class X can be called by a subclass of X without explicitly referencing the class X.

F

A method with the same signature as a private final method in class X can be implemented in a subclass of X.

G

A protected method in class X can be overridden by a subclass of X only if the subclass is in the same package as X.

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

package foo;  public class Outer {  public static class Inner {  }  }   Which statement is true?() 

  • A、 Compilation fails.
  • B、 An instance of the Inner class can be constructed with “new Outer.Inner()”.
  • C、 An instance of the Inner class cannot be constructed outside of package foo.
  • D、 An instance of the Inner class can be constructed only from within the Outer class.
  • E、 From within the package foo, and instance of the Inner class can be constructed with “new Inner()”.

正确答案:B

第2题:

Which two of statements are true?()

  • A、It is possible to synchronize static methods.
  • B、When a thread has yielded as a result of yield(), it releases its locks.
  • C、When a thread is sleeping as a result of sleep(), it releases its locks.
  • D、The Object.wait() method can be invoked only from a synchronized context.
  • E、The Thread.sleep() method can be invoked only from a synchronized context.
  • F、When the thread scheduler receives a notify() request, and notifies a thread, that thread immediately releases its lock.

正确答案:A,D

第3题:

10. class Foo {  11. static void alpha() { /* more code here */ }  12. void beta() { /* more code here */ }  13. }  Which two are true?()

  • A、 Foo.beta() is a valid invocation of beta().
  • B、 Foo.alpha() is a valid invocation of alpha().
  • C、 Method beta() can directly call method alpha().
  • D、 Method alpha() can directly call method beta().

正确答案:B,C

第4题:

It is desirable that a certain method within a certain class can only be accessed by classes that are defined within the same package as the class of the method. How can such restrictions be enforced?()  

  • A、Mark the method with the keyword public.
  • B、Mark the method with the keyword protected.
  • C、Mark the method with the keyword private.
  • D、Mark the method with the keyword package.
  • E、Do not mark the method with any accessibility modifiers.

正确答案:E

第5题:

package foo; public class Outer (  public static class Inner (  )  )   Which statement is true? () 

  • A、 An instance of the Inner class can be constructed with “new Outer.Inner ()”
  • B、 An instance of the inner class cannot be constructed outside of package foo.
  • C、 An instance of the inner class can only be constructed from within the outer class.
  • D、 From within the package bar, an instance of the inner class can be constructed with “new inner()”

正确答案:A

第6题:

public class SyncTest {  private int x;  private int y;  private synchronized void setX( int i ) { x = i; }  private synchronized void setY( int i ) { y = i; }  public void setXY( int i ) { setX(i); setY(i); }  public synchronized boolean check() { return x != y; }  }   Under which condition will check return true when called from a different class? () 

  • A、 check can never return true.
  • B、 check can return true when setXY is called by multiple threads.
  • C、 check can return true when multiple threads call setX and setY separately.
  • D、 check can return true only if SyncTest is changed to allow x and y to be set separately.

正确答案:B

第7题:

public class SyncTest (  private int x;  private int y;  private synchronized void setX (int i) (x=1;)  private synchronized void setY (int i) (y=1;)  public void setXY(int 1)(set X(i); setY(i);)  public synchronized Boolean check() (return x !=y;)  )  Under which conditions will check () return true when called from a different class?   

  • A、 Check() can never return true.
  • B、 Check() can return true when setXY is called by multiple threads.
  • C、 Check() can return true when multiple threads call setX and setY separately.
  • D、 Check() can only return true if SyncTest is changed to allow x and y to be setseparately.

正确答案:B

第8题:

Which two statements are true?()

  • A、 An inner class may be declared as static.
  • B、 An anonymous inner class can be declared as public.
  • C、 An anonymous inner class can be declared as private.
  • D、 An anonymous inner class can extend an abstract class.
  • E、 An anonymous inner class can be declared as protected.

正确答案:A,D

第9题:

Which the following two statements are true?()

  • A、 An inner class may be declared as static.
  • B、 An anonymous inner class can be declared as public.
  • C、 An anonymous inner class can be declared as private.
  • D、 An anonymous inner class can extend an abstract class.
  • E、 An anonymous inner class can be declared as protected.

正确答案:A,D

第10题:

Which statement is true?()

  • A、 An anonymous inner class may be declared as final.
  • B、 An anonymous inner class can be declared as private.
  • C、 An anonymous inner class can implement multiple interfaces.
  • D、 An anonymous inner class can access final variables in any enclosing scope.
  • E、 Construction of an instance of a static inner class requires an instance of the enclosing outer class.

正确答案:D

更多相关问题