失效链接处理 |
2020年全网最全BAT笔试面试题打包分享 PDF 下载 2020年全网最全BAT笔试面试题打包分享!!! 呕心沥血,熬夜苦逼加班整理,希望对大伙有用,坚持每日分享一套Java学习资源干货,一起提高,一起进步!!!
2020年全网最全BAT笔试面试题打包获取方式:
微信扫码关注Java资料站公众号
主要内容:
选择题
1:
1.What will happen when you attempt to compile and run the following code?
2.
3.class Base
4.
5.{
6.
7.int i = 99;
8.
9.public void amethod()
10.
11.{
12.
13. System.out.println("Base.amethod()");
14.
15. }
16.
17. Base()
18.
19.{
20.
21. amethod();
22.
23. }
24.
25.}
26.
27.public class Derived extends Base
28.
29.{
30.
31.int i = -1;
32.
33.
34.
35.public static void main(String argv[])
36.
37.{
38.
39. Base b = new Derived();
40.
41. System.out.println(b.i);
42.
43. b.amethod();
44.
45. }
46.
47. public void amethod()
48.
49.{
50.
51. System.out.println("Derived.amethod()");
52.
53. }
54.
55.}
56.
57.Choices:
A.Derived.amethod() -1 Derived.amethod()
B.Derived.amethod() 99
C.Compile time error
D.Derived.amethod()
2:
1.Which is the most appropriate code snippet that can be inserted at line 18 in the following code?
2.
3.(Assume that the code is compiled and run with assertions enabled)
4.
5.1. import java.util.*;
6.
7.2.
8.
9.3. public class AssertTest
10.
11.4. {
12.
13.5. private HashMap cctld;
14.
15.6.
16.
17.7. public AssertTest()
18.
19.8. {
20.
21.9. cctld = new HashMap();
22.
23.10. cctld.put("in", "India");
24.
25.11. cctld.put("uk", "United Kingdom");
26.
27.12. cctld.put("au", "Australia");
28.
29.13. // more code...
30.
31.14. }
32.
33.15. // other methods ....
34.
35.16. public String getCountry(String countryCode)
36.
37.17. {
38.
39.18. // What should be inserted here?
40.
41.19. String country = (String)cctld.get(countryCode);
42.
43.20. return country;
44.
45.21. }
46.
47.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";
|