网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
classAccount{privateintbalance;publicvoidsetBalance(intb){balance=b;}publicintgetBalance(){returnbalance;}publicvoidclearBalance(){balance=0;}}哪一个改变可以使Account类线程安全?()
A.在第2行加synchronized修饰符。
B.在第3行加synchronized修饰符。
C.在第3行、第4行和第6行加synchronized修饰符。
D.在第4行、第6行和第8行加synchronized修饰符。
参考答案
更多 “ classAccount{privateintbalance;publicvoidsetBalance(intb){balance=b;}publicintgetBalance(){returnbalance;}publicvoidclearBalance(){balance=0;}}哪一个改变可以使Account类线程安全?() A.在第2行加synchronized修饰符。B.在第3行加synchronized修饰符。C.在第3行、第4行和第6行加synchronized修饰符。D.在第4行、第6行和第8行加synchronized修饰符。 ” 相关考题
考题
I pointed out to him that the incorrectly looped string had thrown the toy ______balance.
A. inB. loseC. offD. slip
考题
阅读下列代码片段Class InterestTest________ActionListener{Public void actionPerformed (ActionEvent event) {Double interest = balance * rate/100;Balance += interest;Number Format format =Number Format.getCurrencyInstance ();System.out.printlb{ “ balance = ” +Formatter.format (balance)};}Private double rate;}在下划线处,应填的正确选项是A ) ImplementationB ) InneritanceC ) implementsD ) extends
考题
阅读下面代码 class InterestTest ______ ActionListener { … public void actionPerformed(ActionEvent event) { double interest=balance * rate/100: balance+=interest: NumberFormat format=NumberFormat.getCurrencyInstance(); System.out.printlb("balance="+Formatter.format(balance)); } Private double rate; } 在下画线处,应填入的正确选项是A.implementationB.inheritanceC.implementsD.extends
考题
阅读下列代码片段 class InterestTest——ActionListener{ public"void actionPerformed(ActionEvent event){ double interest=balance*rate/1 00 ; balance+=interest; NumberFormat format=NumberFormat.getCur- rencyInstance; System.OUt.print]b("balance="+formatter. format(balance)); } Private double rate; } 在下画线处,应填的正确选项是( )。A.ImplementationB.InheritanceC.implementsD.extends
考题
现有人编写了帐号类Account,用于管理个人的存款余额, public Account{ private double balance; //帐号余额,余额最低为0 public double getBalance(){ return balance; } Public void setBalance(double b){ balance=b; } public double withdrawl(double money) throws Exception { //取款,money如果为负数或余额不足,抛出异常 } } 请用错误推测法为withdrawl()函数至少设计3个测试用例,并写出基于Junit的测试代码 。
考题
阅读下列代码片段 class InterestTest______ActionListener{ public voidactionPerformed(ActionEventevent){ double interest=balance*rate/100; balance+=interest; NumberFormat format=Number Format.getCurrencylnstance(): System.out.print]b("balance="+formatter.format(balance)}; } Privatedoublerate; } 在下划线处,应填的正确选项是( )。A.ImplementationB.InheritanceC.implementsD.extends
考题
阅读以下说明、Java代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】IC卡和200卡都是从电话卡派生的。下面的程序将电话卡定义为抽象类。其中 balance为双精度变量,代表电话卡中的余额;cardNumber是长整型变量,代表电话卡的卡号;password是整型变量,代表电话卡的密码;connectNumber是字符串变量,代表电话卡的接入号码;connected是布尔变量,代表电话是否接通。performDial()实现各种电话接通后的扣除费用的操作。其中200卡每次通话扣除0.5元的通话费用和附加费用;IC卡每次通话扣除0.9元的通话费。TimeLeft()方法用于测试电话卡余额还可以拨打电话的次数。performConnection()用于电话接入操作,如果卡号和密码正确,则接通;否则,接不通。【程序】abstract class PhoneCard{doubte balace;(1) perfermDial();double getBalance(){ return balance; }double TimeLeft(){double current=balance;int times=0;do{(2)times++;}white(balance>=0);balance=current;return times-1;}}abstract class Number_PhoneCard extends PhoneCard{long cardNumber:int password;String connectNumber;Boolean connected;Boolean performConnection(long cn, int pw){if(cn==cardNumber (3) ){connected=true;return true;}else return false;}}class IC Card (4){boolean performDial(){if(balance>0.9){balance-=0.9;return true;}else return false;}}class D200_Card (4){static double additoryFee;static{ additoryFee=0.1; }boolean performDial(){if(balance>(0,5+additeryFee)){(5)return true;}else return false;}}
考题
写出下面代码的运行结果。def addInterest(balance,rate): newBalance=balance*(1+rate) balance=newBalance def main(): amount=1000 rate=0.05 addInterest(amount,rate) print (amount) main()
热门标签
最新试卷