• 2021-04-14
    【单选题】下面的代码实现了设计模式中的()模式 public class A{ private A instance; private A(){} public static Aget Instance{ if(A==null) instance = new A(); return instance; } }
    A. Factory B. AbstractFactory C. Singleton D. Builder
  • Singleton

    内容

    • 0

      An instance member() A: is also called a static member B: is always a variable C: is never a method D: belongs to a single instance, not to the class as a whole E: always represents an operation

    • 1

      如下代码:public class X {public X aMethod() { return this;}}public class Y extends X { }哪两个方法能加到Y类的定义中? A: public void aMethod(String s) {} B: public void aMethod() {} C: private Y aMethod() { return null; } D: public X aMethod() { return new Y(); } E: private void aMethod() {}

    • 2

      中国大学MOOC: There are following business statements for an information system:①A customer submit 0 or more orders;②An order can only be submitted by one customer. There are two classes in the system “Customer” and “Order”. For each instance of Order Class, there are ____ instance(s) of Customer Class; while for each instance of Customer Class, there are ____ instance(s) of Order Class.

    • 3

      public class enclosingone (    public class insideone{}   )   public class inertest(   public static void main (stringargs)(   enclosingone eo= new enclosingone ();    //insert code here  )  )   Which statement at line 7 constructs an instance of the inner class?() A:  InsideOnew ei= eo.new InsideOn(); B:  Eo.InsideOne ei = eo.new InsideOne(); C:  InsideOne ei = EnclosingOne.new InsideOne(); D:  EnclosingOne.InsideOne ei = eo.new InsideOne();

    • 4

      中国大学MOOC: 如果有以下程序片段public class Some{ private Some some; private Some(){} public static Some create(){ if(some==null) some = new Some(); return some; }}以下描述正确的是