niusouti.com

publicclassNamedCounter{privatefinalStringname;privateintcount;publicNamedCounter(Stringname){this.name=name;}publicStringgetName(){returnname;}publicvoidincrement(){coount++;}publicintgetCount(){returncount;}publicvoidreset(){count=0;}}Whichthreechangess

题目

publicclassNamedCounter{privatefinalStringname;privateintcount;publicNamedCounter(Stringname){this.name=name;}publicStringgetName(){returnname;}publicvoidincrement(){coount++;}publicintgetCount(){returncount;}publicvoidreset(){count=0;}}Whichthreechangesshouldbemadetoadaptthisclasstobeusedsafelybymultiplethreads?()

A.declarereset()usingthesynchronizedkeyword

B.declaregetName()usingthesynchronizedkeyword

C.declaregetCount()usingthesynchronizedkeyword

D.declaretheconstructorusingthesynchronizedkeyword

E.declareincrement()usingthesynchronizedkeyword


相似考题
更多“publicclassNamedCounter{privatefinalStringname;privateintcount;publicNamedCounter(Stringna ”相关问题
  • 第1题:

    类 MyClass 中,下列哪条语句定义了一个只读的属性 Count

    A.private int Count;#B.private int count; public int Count{ get{ return count; } }#C.public readonly int Count;#D.public readonly int Count{ get{ return count; } set{ count = value; } }
    private int count; public int Count{ get{ return count; } }

  • 第2题:

    类 MyClass 中,下列哪条语句定义了一个只读的属性 Count?

    A.private int Count;#B.private int count; public int Count { get{ return count; } }#C.public readonly int Count;#D.public readonly int Count { get{ return count; } set{ count = value; } }
    B

  • 第3题:

    【单选题】类MyClass 中,下列哪条语句定义了一个只读的属性Count?(3 分)

    A.private int Count;#B.private int count; public int Count{ get{return count;} }#C.public readonly int Count;#D.public readonly int Count { get{ return count;} set{count = value;} }
    private int count;public int Count{get{return Count:}}

  • 第4题:

    【单选题】类MyClass 中,下列哪条语句定义了一个只读的属性Count?(2 分)

    A.private int Count;#B.private int count; public int Count{ get{return count;} }#C.public readonly int Count;#D.public readonly int Count { get{ return count;} set{count = value;} }
    B 解析:本题考核构造函数和析构函数。题中定义了类MyClass的对象a,对象数据b,所以调用了构造函数3次,输出111。然后定义了对象指针*p[2],由于指针没有实例话,所以不会调用构造函数。

  • 第5题:

    类 MyClass 中,下列哪条语句定义了一个只读的属性 Count?

    A.private int Count;#B.public readonly int Count { get { return count; } set { count = value; } }#C.private int count; public int Count { get { return count; } }#D.public readonly int Count;
    B