-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathshanzhenqiang(JAVA测试题(三套含答案)).yml
executable file
·958 lines (918 loc) · 20.5 KB
/
shanzhenqiang(JAVA测试题(三套含答案)).yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
# 单选题
- kind: single_choice
content: 在单一文件中 import、class 和 package 的正确出现顺序是:
content_format: text
answer:
choices:
- id: aaa
text: package, import, class
- id: bbb
text: class, import, package
- id: ccc
text: import, package, class
- id: ddd
text: package, class, import
correct: aaa
points:
- 语法基础
- kind: single_choice
content: |
编译,运行下列代码后的结果是:
```java
public class Test {
public static void main ( String args [] ) {
int age;
age = age + 1;
System.out.println( "The age is " + age );
}
}
```
content_format: md
answer:
choices:
- id: aaa
text: 编译,运行后没有输出
- id: bbb
text: 编译,运行后输出:The age is 1
- id: ccc
text: 能通过编译,但运行时产生错误
- id: ddd
text: 不能通过编译
correct: ddd
points:
- 语法基础
- kind: single_choice
content: 内部数据类型 byte 的取值范围是
content_format: text
answer:
choices:
- id: aaa
text: 0 - 65, 535
- id: bbb
text: (–128) – 127
- id: ccc
text: (–32, 768) – 32,767
- id: ddd
text: (–256) – 255
correct: bbb
points:
- 常见数据类型
- kind: single_choice
content: 声明公用的 abstract 方法的正确格式是
content_format: text
answer:
choices:
- id: aaa
text: public abstract void add();
- id: bbb
text: public abstract void add() {}
- id: ccc
text: public abstract add();
- id: ddd
text: public virtual add();
correct: aaa
points:
- 抽象类,接口,继承
- kind: single_choice
content: |
下面的代码能打印出的结果为:
```java
int i = 1;
switch (i) {
case 0:
System.out.println( "zero" );
break;
case 1:
System.out.println( "one" );
case 2:
System.out.println( "two" );
default:
System.out.println( "default" );
}
```
content_format: md
answer:
choices:
- id: aaa
text: one
- id: bbb
text: one, default
- id: ccc
text: one, two, default
- id: ddd
text: default
correct: ccc
points:
- 语法基础
- kind: single_choice
content: |
下面的代码能打印出的结果为:
```java
int i = 9;
switch (i) {
default:
System.out.println( "default" );
case 0:
System.out.println( "zero" );
break;
case 1:
System.out.println( "one" );
case 2:
System.out.println( "two" );
}
```
content_format: md
answer:
choices:
- id: aaa
text: default
- id: bbb
text: default, zero
- id: ccc
text: error default clause not defined
- id: ddd
text: no output displayed
correct: bbb
points:
- 语法基础
- kind: single_choice
content: |
当你试图准备编译,运行下面代码时会发生:
```java
class Base {}
class Sub extends Base {}
class Sub2 extends Base {}
public class CEx{
public static void main( String argv[] ){
Base b = new Base();
Sub s = ( Sub ) b;
}
}
```
content_format: md
answer:
choices:
- id: aaa
text: 编译和运行很正常
- id: bbb
text: 编译时错误
- id: ccc
text: 运行时错误
correct: ccc
points:
- 类,对象,方法
- kind: single_choice
content: |
当你试图准备编译,运行下面代码时会发生:
```java
public class Tux extends Thread{
static String sName = "vandeleur";
public static void main( String argv[] ){
Tux t = new Tux();
t.piggy( sName );
System.out.println( sName );
}
public void piggy( String sName ){
sName = sName + " wiggy";
start();
}
public void run(){
for(int i = 0; i < 4; i++){
sName = sName + " " + i;
}
}
}
```
content_format: md
answer:
choices:
- id: aaa
text: 编译时错误
- id: bbb
text: 编译成功,并打印出 "vandeleur wiggy"
- id: ccc
text: 编译成功,并打印出 "vandeleur wiggy 0 1 2 3"
- id: ddd
text: 编译成功,并打印出 "vandelur"
correct: ddd
points:
- 类,对象,方法
- kind: single_choice
content: 在什么情况下类获得默认的构造方法:
content_format: text
answer:
choices:
- id: aaa
text: 类被定义时
- id: bbb
text: 类中没有定义任何构造方法时
- id: ccc
text: 在类中至少定义了一个构造方法时
correct: bbb
points:
- 类,对象,方法
- kind: single_choice
content: 假定有一个包含引起异常(不是一个 RuntimeException )的代码的方法,用什么方式告诉方法的调用者要捕获该异常:
content_format: text
answer:
choices:
- id: aaa
text: throw Exception
- id: bbb
text: throws Exception
- id: ccc
text: new Exception
- id: ddd
text: 不用特别指定
correct: bbb
points:
- 语法基础
- kind: single_choice
content: 运行下面代码能够得出的结果?
content_format: text
answer:
choices:
- id: aaa
text: throw Exception
- id: bbb
text: throws Exception
- id: ccc
text: new Exception
- id: ddd
text: 不用特别指定
correct: bbb
points:
- 语法基础
- kind: single_choice
content: |
```java
System.out.println( 4 | 3 );
```
能打印出什么结果?
content_format: md
answer:
choices:
- id: aaa
text: 6
- id: bbb
text: 0
- id: ccc
text: 1
- id: ddd
text: 7
correct: ddd
points:
- 语法基础
- kind: single_choice
content: |
传递 4,0 来运行下列代码中的方法 divide( int a, int b ),结果是:
```java
public void divide( int a, int b ) {
try {
int c = a / b;
} catch ( Exception e ) {
System.out.print( "Exception" );
} finally {
System.out.println( "Finally" );
}
}
```
content_format: md
answer:
choices:
- id: aaa
text: '打印输出: Exception Finally'
- id: bbb
text: '打印输出: Finally'
- id: ccc
text: '打印输出: Exception'
- id: ddd
text: 没有任何输出
correct: aaa
points:
- 语法基础
- kind: single_choice
content: 对 public void add( int a ) {…}方法的重写方法:
content_format: text
answer:
choices:
- id: aaa
text: 必须返回 void
- id: bbb
text: 必须返回 in
- id: ccc
text: 可以返回任何需要的类型
correct: aaa
points:
- 类,对象,方法
- kind: single_choice
content: 对 public void add( int a ) {…}方法的重载方法应返回:
content_format: text
answer:
choices:
- id: aaa
text: void
- id: bbb
text: int
- id: ccc
text: 任何类型
correct: ccc
points:
- 类,对象,方法
- kind: single_choice
content: |
下列类分别在不同的文件中定义:
```java
class Vehicle {
public void drive() {
System.out.println( "Vehicle: drive" );
}
}
class Car extends Vehicle {
public void drive() {
System.out.println( "Car: drive" );
}
}
public class Test {
public static void main ( String args [] ) {
Vehicle v;
Car c;
v = new Vehicle();
c = new Car();
v.drive();
c.drive();
v = c;
v.drive();
}
}
```
编译和执行类 Test 后,结果是:
content_format: md
answer:
choices:
- id: aaa
text: 在语句 v = c; 处产生编译时错误
- id: bbb
text: 在语句 v = c; 处产生运行时错误
- id: ccc
text: '输出 Vehicle: drive, Car: drive, Car: drive'
- id: ddd
text: '输出 Vehicle: drive, Car: drive, Vehicle: drive'
correct: ccc
points:
- 类,对象,方法
- kind: single_choice
content: 在子类构造方法内的什么位置可以对超类的构造方法 ( super() ) 进行调用:
content_format: text
answer:
choices:
- id: aaa
text: 子类构造方法的任何地方
- id: bbb
text: 子类构造方法的第一条语句处
- id: ccc
text: 子类构造方法的最后一条语句处
- id: ddd
text: 不能对超类的构造方法进行调用
correct: bbb
points:
- 类,对象,方法
- kind: single_choice
content: |
下列代码中有明显的语法错误的语句是:
```java
1. public class Test {
2. public static void main ( String args [] ) {
3. Employee e = new Employee( "Bob", 48 );
4. e.calculatePay();
5. System.out.println( e.printDetails() );
6. e = Null;
7. e = new Employee( "Denise", 36 );
8. e.calculatePay();
9. System.out.println( e.printDetails() );
10. }
}
```
content_format: md
answer:
choices:
- id: aaa
text: Line 10
- id: bbb
text: Line 11
- id: ccc
text: Line 6
- id: ddd
text: Line 8
correct: ccc
points:
- 语法基础
- kind: single_choice
content: |
下面的代码编译,运行后得出的结果:
```java
ublic class Conv{
public static void main( String argv[] ){
Conv c = new Conv();
String s = new String( "ello" );
c.amethod( s );
}
public void amethod( String s ){
char c = 'H';
c += s;
System.out.println( c );
}
}
```
content_format: md
answer:
choices:
- id: aaa
text: 编译成功,打印出 "Hello"
- id: bbb
text: 编译成功,打印出 "ello"
- id: ccc
text: 编译成功,打印出 elloH
- id: ddd
text: 编译错误
correct: ddd
points:
- 常见数据类型
- kind: single_choice
content: |
执行后打印的结果为:
```java
public class Oct{
public static void main( String argv[] ){
Oct o = new Oct();
o.amethod();
}
public void amethod(){
int oi = 012;
System.out.println( oi );
}
}
```
content_format: md
answer:
choices:
- id: aaa
text: 12
- id: bbb
text: 012
- id: ccc
text: 10
- id: ddd
text: 10.0
correct: ccc
points:
- 常见数据类型
- kind: single_choice
content: |
编译,执行下面的代码会出现的结果:
```java
public class Ref{
public static void main( String argv[] ){
Ref r = new Ref();
r.amethod( r );
}
public void amethod( Ref r ){
int i = 99;
multi( r );
System.out.println( i );
}
public void multi( Ref r ){
r.i = r.i * 2;
}
}
```
content_format: md
answer:
choices:
- id: aaa
text: 一个编译时错误
- id: bbb
text: 99
- id: ccc
text: 198
- id: ddd
text: 一个运行时错误
correct: aaa
points:
- 类,对象,方法
- kind: single_choice
content: 现在你存储一个唯一的整型序列,那么你需要哪个容器接口?
content_format: text
answer:
choices:
- id: aaa
text: Set
- id: bbb
text: List
- id: ccc
text: Map
- id: ddd
text: Vector
correct: aaa
points:
- 常见数据类型
- kind: single_choice
content: |
```java
System.out.println( Math.floor(-2.1) );
```
打印的结果为:
content_format: md
answer:
choices:
- id: aaa
text: -2
- id: bbb
text: 2.0
- id: ccc
text: -3
- id: ddd
text: -3.0
correct: ddd
points:
- 常用基础类库
- kind: single_choice
content: 下面的语句中正确的表达式为。
content_format: text
answer:
choices:
- id: aaa
text: byte b = 128;
- id: bbb
text: boolean n = null;
- id: ccc
text: double d = 0.9239d;
- id: ddd
text: float f = 0.9239;
correct: ccc
points:
- 语法基础
- kind: single_choice
content: 将一个十六进制值赋给一个 long 型变量的正确写法为。()
content_format: text
answer:
choices:
- id: aaa
text: long number = 345L;
- id: bbb
text: long number = 0345;
- id: ccc
text: long number = 0345L;
- id: ddd
text: long number = 0x345L;
correct: ddd
points:
- 语法基础
- kind: single_choice
content: |
以下程序代码的输出是。()
```java
public class test (
public static void main ( String args[] ) (
System.out.printIn( 6 ^ 3 );
)
)
```
content_format: md
answer:
choices:
- id: aaa
text: 3
- id: bbb
text: 5
- id: ccc
text: 6
- id: ddd
text: 11
correct: ddd
points:
- 语法基础
- kind: single_choice
content: |
以下程序代码执行后,哪个说法正确?()
```java
int index = 1;
boolean[] test = new Boolean[3];
boolean foo = test[index];
```
content_format: md
answer:
choices:
- id: aaa
text: 有异常抛出。
- id: bbb
text: 无法编译。
- id: ccc
text: foo 的值是 0。
- id: ddd
text: foo 的值是 null。
- id: eee
text: foo 的值是 true。
- id: fff
text: foo 的值是 false。
correct: bbb
points:
- 常见数据类型
# 多选题
- kind: multi_choice
content: 下列说法错误的有()
content_format: text
answer:
choices:
- id: aaa
text: 数组是一种对象
- id: bbb
text: 数组属于一种原生类
- id: ccc
text: int number = [] = {31,23,33,43,35,63}
- id: ddd
text: 数组的大小可以任意改变
corrects:
- bbb
- ccc
- ddd
points:
- 常见数据类型
- kind: multi_choice
content: 在下面的选项中合法的标识符有。()
content_format: text
answer:
choices:
- id: aaa
text: _ok
- id: bbb
text: "*point"
- id: ccc
text: this
- id: ddd
text: $byte
- id: eee
text: const
- id: fff
text: ILikeJLCSS
corrects:
- aaa
- ddd
- eee
- fff
points:
- 语法基础
- kind: multi_choice
content: 下面的叙述中正确的有。()
content_format: text
answer:
choices:
- id: aaa
text: equals() 方法判定引用值是否指向同一对象。
- id: bbb
text: == 操作符判定两个分立的对象的内容和类型是否一致。
- id: ccc
text: equals() 方法只有在两个对象的内容一致时返回 true。
- id: ddd
text: 类 File 重写方法 equals() 在两个分立的对象的内容和类型一致时返回 true。
corrects:
- ccc
points:
- 类,对象,方法
- kind: multi_choice
content: |
一个类 Example 的 main() 方法的参数是 args, 类被如下调用执行:
```
java Example cat
```
main 方法中访问 args[0] 的输出是什么?
content_format: md
answer:
choices:
- id: aaa
text: cat
- id: bbb
text: java
- id: ccc
text: Example
- id: ddd
text: 抛出一个 NullPointerException 异常
- id: eee
text: 抛出一个 ArrayIndexOutOfBoundsException 异常
corrects:
- aaa
points:
- 类,对象,方法
- kind: multi_choice
content: |
给出下列代码,请选择 2 个正确输出?
```java
public class Example{
public static void main( String args[] ){
int i = 0;
do{
System.out.println( "Doing it for i is" + i );
}
while ( --i > 0 );
System.out.println( "Finished" );
}
}
```
content_format: md
answer:
choices:
- id: aaa
text: Doing it for i is 3
- id: bbb
text: Doing it for i is 2
- id: ccc
text: Doing it for i is 1
- id: ddd
text: Doing it for i is 0
- id: eee
text: Finished
corrects:
- ddd
- eee
points:
- 语法基础
- kind: multi_choice
content: 选择定义在 Graphics 类中的方法:
content_format: text
answer:
choices:
- id: aaa
text: drawLine( int, int, int, int );
- id: bbb
text: drawImage( Image, int, int, ImageObserver );
- id: ccc
text: drawString( String, int, int );
- id: ddd
text: add( Component );
- id: eee
text: setVisible( boolean );
- id: fff
text: setLayout( Object );
corrects:
- aaa
- ccc
points:
- 常用基础类库
- kind: multi_choice
content: 选择可以建立线程的接口:
content_format: text
answer:
choices:
- id: aaa
text: Runnable
- id: bbb
text: Run
- id: ccc
text: 少数用于管理的系统部件
- id: ddd
text: Thread
- id: eee
text: Executable
corrects:
- aaa
points:
- 线程
- kind: multi_choice
content: |
下面定义的变量能执行哪些操作?
```java
String s1 = new String( "Hello" );
String s2 = new String( "there" );
String s3 = new String();
```
content_format: md
answer:
choices:
- id: aaa
text: s3 = s1 + s2;
- id: bbb
text: s3 = s1 - s2;
- id: ccc
text: s3 = s1 & s2;
- id: ddd
text: s3 = s1 && s2;
corrects:
- aaa
points:
- 常见数据类型
- kind: multi_choice
content: |
那个代码能够添加在 //Method here 地方,并能正确执行?
```java
class Base{
public void amethod( int i ) { }
}
public class Scope extends Base{
public static void main( String argv[] ){
}
//Method Here
}
```
content_format: md
answer:
choices:
- id: aaa
text: void amethod( int i ) throws Exception {}
- id: bbb
text: void amethod( long i )throws Exception {}
- id: ccc
text: void amethod( long i ){}
- id: ddd
text: public void amethod( int i ) throws Exception {}
corrects:
- bbb
- ccc
points:
- 语法基础
- kind: multi_choice
content: public static void main 方法的参数描述是:
content_format: text
answer:
choices:
- id: aaa
text: String args[]
- id: bbb
text: Strings args[]
- id: ccc
text: String args
- id: ddd
text: String []args
corrects:
- aaa
- ddd
points:
- 语法基础
- kind: multi_choice
content: 下面哪行代码会在编译的时候出现错误或警告:
content_format: text
answer:
choices:
- id: aaa
text: float f = 1.3;
- id: bbb
text: char c = "a";
- id: ccc
text: byte b = 257;
- id: ddd
text: boolean b = null;
- id: eee
text: int i = 10;
corrects:
- aaa
- bbb
- ccc
- ddd
points:
- 语法基础
- kind: multi_choice
content: 下面哪些关键字不是 JAVA 的关键字
content_format: text
answer:
choices:
- id: aaa
text: if
- id: bbb
text: then
- id: ccc
text: goto
- id: ddd
text: while
- id: eee
text: case
corrects:
- bbb
points:
- 语法基础
- kind: multi_choice
content: 下面哪些不是合法的变量定义?
content_format: text
answer:
choices:
- id: aaa
text:
"2variable"
- id: bbb
text:
"variable2"
- id: ccc
text:
"_whatavariable"
- id: ddd
text:
"_3_"
- id: eee
text:
"aaaa"
- id: fff
text:
"#myvar"
corrects:
- aaa
- fff
points:
- 语法基础