《北京达内科技有限公司 Java培训讲师》由会员分享,可在线阅读,更多相关《北京达内科技有限公司 Java培训讲师(15页珍藏版)》请在金锄头文库上搜索。
1、编号:时间:2021年x月x日书山有路勤为径,学海无涯苦作舟页码:第1页 共1页选择题 1:在软件生命周期中,下列哪个说法是不准确的? A.软件生命周期分为计划、开发和运行三个阶段 B.在计划阶段要进行问题焉醛和需求分析 C.在开发后期要进行编写代码和软件测试 D.在运行阶段主要是进行软件维护 2: Whichisthemostappropriatecodesnippetthatcanbeinsertedatline18inthefollowingcode? (Assumethatthecodeiscompiledandrunwithassertionsenabled) 1.importjav
2、a.util.*; 2. 3.publicclassAssertTest 4. 5.privateHashMapcctld; 6. 7.publicAssertTest() 8. 9.cctld=newHashMap(); 10.cctld.put(in,India); 11.cctld.put(uk,UnitedKingdom); 12.cctld.put(au,Australia); 13./morecode. 14. 15./othermethods. 16.publicStringgetCountry(StringcountryCode) 17. 18./Whatshouldbeins
3、ertedhere? 19.Stringcountry=(String)cctld.get(countryCode); 20.returncountry; 21. 22.Which is the most appropriate code snippet that can be inserted at line 18 in the following code?(Assume that the code is compiled and run with assertions enabled)1. import java.util.*;2. 3. public class AssertTest4
4、. 5. private HashMap cctld;6. 7. public AssertTest()8. 9. cctld = new HashMap();10. cctld.put(in, India);11. cctld.put(uk, United Kingdom);12. cctld.put(au, Australia);13. / more code. 14. 15. / other methods . 16. public String getCountry(String countryCode)17. 18. / What should be inserted here?19
5、. String country = (String)cctld.get(countryCode);20. return country;21. 22. A.assert countryCode != null; B.assert countryCode != null : Country code can not be null ; C.assert cctld != null : No country code data is available; D.assert cctld : No country code data is available; 3: Givethefollowing
6、code: publicclassExample publicstaticvoidmain(Stringargs) intl=0; do System.out.println(“Doingitforlis:”+l); while(-l0) System.out.println(“Finish”); Whichwellbeoutput:Give the following code:public class Examplepublic static void main(String args )int l=0;doSystem.out.println(“Doing it for l is:”+l
7、);while(-l0)System.out.println(“Finish”);Which well be output: A.Doing it for l is 3 B.Doing it for l is 1 C.Doing it for l is 2 D.Doing it for l is 0 4: Givethisclassoutline: classExample privateintx; /restofclassbody AssumingthatxinvokedbythecodejavaExample,whichstatementcanmadexbedirectlyaccessib
8、leinmain()methodofExample.java?Give this class outline:class Exampleprivate int x;/rest of class bodyAssuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of Example.java?A.Change private int x to public int x B.change private int x to s
9、tatic int x C.Change private int x to protected int x D.change private int x to final int x 5:Which of the following statements are not legal? A.long l = 4990; B.int i = 4L; C.double d = 34.4; D.double t = 0.9F. 6:鉴于Java的特点,它最适合的计算环境是 A.并行计算环境 B.分布式计算环境 C.高强度计算环境 D.开放式计算环境 7:What is written to the s
10、tandard output given the following statement:System.out.println(4|7); Select the right answer: A.4 B.5 C.6 D.7 8: 1.publicclassX 2.publicobjectm() 3.objecto=newfloat(3.14F); 4.objectoa=newobject1; 5.oa0=o; 6.o=null; 7.oa0=null; 8.returno; 9. 10. Whenisthefloatobjectcreatedinline3,eligibleforgarbagec
11、ollection? 1. public class X 2. public object m () 3. object o = new float (3.14F); 4. object oa = new object 1; 5. oa0= o; 6. o = null; 7. oa0 = null; 8.return o; 9. 10. When is the float object created in line 3, eligible for garbage collection? A.Just after line 5 B.Just after line 6 C.Just after
12、 line 7 D.Just after line 8(that is, as the method returns) 9: Consider the class hierarchy shown below: - class FourWheeler implements DrivingUtilities class Car extends FourWheeler class Truck extends FourWheeler class Bus extends FourWheeler class Crane extends FourWheeler - Consider the following code below: 1.DrivingUtilities du; 2.FourWheeler fw; 3.Truck myTruck = new Truck(); 4.du = (DrivingUtilities