-
Notifications
You must be signed in to change notification settings - Fork 208
/
PRJ311.txt
1270 lines (1269 loc) · 140 KB
/
PRJ311.txt
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
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1.Which of these method is used to implement Runnable interface? | run
2.Which of these interface is implemented by Thread class? | runnable
3.Which of these method waits for the thread to treminate? | join()
4.Which of these statement is incorrect? | run() method is used to begin execution of a thread before start() method in special
5. class newthread implements Runnable | My thread
6.class newthread implements Runnable | Thread[New Thread,10,main]
7.Which of these method can be used to make the main thread to be executed last among all the threads? | sleep()
8.Which of these method is used to find out that a thread is still running or not? | isAlive()
9.What is the default value of priority variable MIN_PRIORITY AND MAX_PRIORITY? | 1 & 10
10.Which of these method is used to explicitly set the priority of a thread? | setPriority()
11.What is synchronization in reference to a thread? | t's a process of handling situations when two or more threads need access to a shared resource.
12.class newthread extends Thread | runtime error
13.Which of these class is used to make a thread? | runnalble
14.Which of these method of Thread class is used to find out the priority given to a thread? | getPriority()
15.Which of these method of Thread class is used to Suspend a thread for a period of time? | sleep()
16.What is multithreaded programming? | It's a process in which two or more parts of same process run simultaneously.
17.Which of these are types of multitasking? | Process and Thread based
18.Which of these packages contain all the Java's built in exceptions? | java.io
19.What will happen if two thread of same priority are called to be processed simultaneously? | It is dependent on the operating system.
20.Which of these statements is incorrect? | A thread can exist only in two states, running and blocked.
21.Which of the following layout managers honours the preferred size of a component: | GridLayout
22.You should always invoke the unlock method in the finally clause. | true
23.Given the following code, which set of code can be used to replace the comment so that the program displays time to the console every second? | try { Thread.sleep(1000); } catch(InterruptedException e) { }
24.Which of the following expressions must be true if you create a thread using Thread = new Thread(object)? | object instanceof Runnable
25.How do you create a condition on a lock? | Condition condition = lock.newCondition();
26.The Runnable interface is more general than the Thread class. You can convert any class that extends Thread to a class that implements Runnable. | true
27. An exception occurs if the resume() method is invoked by a finished thread object. | true
28.You should not directly invoke the run() method of a thread object. | true
29.When creating a server on a port that is already in use,the server encounters a fatal error and must be terminated. | java.net.BindException occurs.
30.To obtain an ObjectInputStream from a socket, use | socket.getObjectStream()
31.You can invoke _on a Socket object, say socket, to obtain an InetAddress object. | socket.getInetAddress();
32.To connect to a server running on the same machine with the client, which of the following can be used for the hostname? | All of the above
33.The server listens for a connection request from a client using the following statement: | Socket s = serverSocket.accept()
34.The server can create a server socket regardless of whether the port is in use or not. | false
35.The client can connect to the server regardless of whether the port is in use or not. | true
36.You cannot get instances of InputStream or OutputStream because InputStream and OutputStream are abstract classes. | false
37.An applet cannot connect to a server program on a Web server where the applet was loaded. | true
38.You can transmit objects over the socket. | true
39.The URL constructor throws MalformedURLException if the URL is syntactically incorrect. | false
40.getInputStream() and getOutputStream() are used to produce InputStream and OutputStream on the socket. | true
41.Which of the following statements are true? | You can create an instance of NumberFormat using the static factory methods in NumberFormat.
42.Which of the following are in the java.text package? | DateFormat+SimpleDateFormat+Date
43.Which of the following code is correct to obtain hour from a Calendar object cal? | cal.get(Calendar.HOUR);
44.How do you create a locale for the United States? | new Locale("en", "US"); + Locale.US;
45.A resource bundle is __ | a Java class file or a text file that provides locale-specific information.
46.To display number in desired format, you have to use the NumberFormat class or its subclasses. | true
47.You can find all the available locales from a Swing object. | false
48.The locale property is in the Component class, thus, every Java Swing component has the locale property. | true
49.You can get year, month, day, hour, minute, and second from an instance of GregorianCalendar. | true
50.You can get hour, minute and second from the Date class. | false
51.The TimeZone class has a static method for obtaining all the available time zone IDs. | true
52.You can get all the available locales from an instance of Calendar, Collator, DateFormat, or NumberFormat. | true
53.You can create a JTable using | ABCD
54.The data in DefaultTableModel are stored in | a Vector
55.DefaultTableModel contains the methods for | adding a column + inserting a new row + adding a new row
56.The autoResizeMode property specifies how columns are resized (you can resize table columns but not rows). | ABCDE
57._________ are the properties in JTable | ABCDE
58.The autoResizeMode property specifies how columns are resized (you can resize table columns but not rows). Possible values are: | ABCDE
59.Invoking Class.forName method may throw | ClassNotFoundException
60.What information may be obtained from a DatabaseMetaData object? | ABCD
61.Which of the following are interfaces? | Statement+ResultSet+Connection
62.In a relational data model, ____defines the representation of the data. | Structure
63.Which of the following statements are true? | you may load multiple JDBC...+B+C+D
64.Which of the following statements loads the JDBC-ODBC driver? | Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
65.To create a statement on a Connection object conn, use | Statement statement = conn.createStatement();
66.SQL ________ statements may change the contents of a database. | INSERT+DELETE+UPDATE
67.A database URL for an access database source test is | jdbc:odbc:test
68.Database meta data are retrieved through ___________ | a Connection object
69.What is the return value from stmt.executeUpdate("insert into T values (100, 'Smith')") | an int value indicating how many rows are effected from the invocation
70.are known as intra-relational constraints, meaning that a constraint involves only one relation | DOMAIN + PRIMARY KEY CONTRAINST
71.A database URL for a MySQL database named test on host panda.armstrong.edu is | jdbc:mysql://panda.armstrong.edu/test
72.In a relational data model, _________ imposes constraints on the data. | Integrity
73.To execute a SELECT statement "select * from Address" on a Statement object stmt, use | tmt.executeQuery("select * from Address");
74.specify the permissible values for an attribute. | Domain constraints
75.Suppose that your program accesses MySQL or Oracle database. Which of the following statements are true? | a+c
76.What information may be obtained from a ResultSetMetaData object? | number of columns in the result set
77. is an attribute or a set of attributes that uniquely identifies the relation. | A superkey
78.Where is com.mysql.jdbc.Driver located? | in a JAR file mysqljdbc.jar
79.Analyze the following code:ResultSet resultSet = statement.executeQuery("select firstName, mi, lastName from Student where lastName "+ " = 'Smith'");System.out.println(resultSet.getString(1)); | BD
80.In a relational data model, ________ provides the means for accessing and manipulating data. | Language+SQL
81.To connect to a local MySQL database named test, use | Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/test");
82.Result set meta data are retrieved through ________ | a ResultSet Object
83.You want to construct a text area that is 80 character-widths wide and 10 character-heights tall. What code do you use? | new TextArea(10, 80)
84.A text field has a variable-width font. It is constructed by calling new TextField("iiiii"). What happens if you change the contents of the text field to "wwwww"? (Bear in mind that i is one of the narrowest characters, and w is one of the widest.) | The text field stays the same width; to see the entire contents you will have to scroll by using the � and � keys.
85.The CheckboxGroup class is a subclass of the Component class. | false
86.What are the immediate super classes of the following classes? | Container class
87.Which Component method is used to access a component's immediate Container? | getParent()
88.Which of the following are direct or indirect subclasses of Component? | Button+Label+Frame
89.Which of the following are direct or indirect subclasses of Container? | Frame+FileDialog+Applet
90.Which method is used to set the text of a Label object? | setText( )
91.Which constructor creates a TextArea with 10 rows and 20 columns? | new TextArea(10, 20)
92.Which of the following creates a List with 5 visible items and multiple selection enabled? | new List(5, true)
93.Which are true about the Container class? | A+B+D
94.Suppose a Panel is added to a Frame and a Button is added to the Panel. If the Frame's font is set to 12-point TimesRoman, the Panel's font is set to 10-point TimesRoman, and the Button's font is not set, what font will be used to display the Button's label? | 10-point TimesRoman
95.A Frame's background color is set to Color. Yellow, and a Button's background color is to Color.Blue. Suppose the Button is added to a Panel, which is added to the Frame. What background color will be used with the Panel? | Colr.Yellow
96.Which method will cause a Frame to be displayed? | show() + setVisible()
97.Which of the following components allow multiple selections? | Non-exclusive Checkboxes+List
98.Which method is method to set the layout of a container? | layout of a container
99.Which method returns the preferred size of a component? | getPreferredSize( )
100.Which layout should you use to organize the components of a container in a tabular form? | GridLayout
101.An application has a frame that uses a Border layout manager. Why is it probably not a good idea to put a vertical scroll bar at North in the frame? | Both a and b.
102.What is the default layouts for a applet, a frame and a panel?Ans : For an applet and a panel, Flow layout is the default layout, whereas Border layout is default layout for a frame.If a frame uses a Grid layout manager and does not contain any panels, then all the components within the frame are the same width and height. | true
103.If a frame uses its default layout manager and does not contain any panels, then all the components within the frame are the same width and height. | false
104.With a Border layout manager, the component at Center gets all the space that is left over, after the components at North and South have been considered. | false
105.An Applet has its Layout Manager set to the default of FlowLayout. What code would be the correct to change to another Layout Manager? | setLayout(new GridLayout(2,2));
106.How do you indicate where a component will be positioned using Flowlayout? | Do nothing, the FlowLayout will position the component
107.How do you change the current layout manager for a container? | Use the setLayout method
108.When using the GridBagLayout manager, each new component requires a new instance of the GridBagConstraints class. Is this statement true or false? | false
109.Which of these methods is used to know the full URL of an URL object | toExternalForm()
110.Which of these class is used to encapsulate IP addres and DNS? | InetAddress
111.Which of these Exception is throw by remote method? | Remote Exception
112.What does URL stand for? | Uniform Resource Locator
113.In java,what do you call an area on the screen that has nice bolders and various button along the top bolder? | frame
114.What is the name of the Swing class that is used for frames? | Jframe
Which of the following are valid declarations? Assume java.util.* is imported. | Vector,Set,Map
You can determine all the keys in a Map in which of the following ways? | By getting a Set object from the Map and iterating through it
What keyword is used to prevent an object from being serialized? | transient
An abstract class can contain methods with declared bodies. | True
Select the order of access modifiers from least restrictive to most restrictive. | public,protected,default,private
Which access modifier allows you to access method calls in libraries not created in Java? | native
Which of the following statements are true? | A final object cannot be reassigned a new address in memory
The keyword extends refers to what type of relationship? | �is a�
Which of the following keywords is used to invoke a method in the parent class? | super
Given the following code, what will be the outcome? public class Funcs extends java.lang.Math{public int add(int x, int y){return x + y;}public int sub(int x, int y){return x - y;}public static void main(String[]a){Funcs f = new Funcs();System.out.println("" + f.add(1, 2));}} | The code does not compile
public class Test {public static void main(String [] a){int [] b = [1,2,3,4,5,6,7,8,9,0]; System.out.println("a[2]=" + a[2]);}} | The code does not compile
x = 23 % 4; | 3
<insert code> | break
What method call is used to tell a thread that it has the opportunity to run? | notify()
Assertions are used to enforce all but which of the following? | Exceptions
The developer can force garbage collection by call System.gc() | False
Select the valid primitive data types. | boolean,char,float
How many bits does a float contain? | 32
What is the value of the x after the following line is executed? x = 32 * (31 - 10 *3) | 32
A StringBuffer is slower than a StringBuilder, but a StringBuffer is threadsafe. | True
Select the list of primitives ordered in smallest bit size representation. | char,int,float,long
Which class provides locale-sensitive text formatting for date and time information? | java.text.DateFormat
int x = 9; byte b = x; | False
Which of the following code snippets compile? | Integer i = 7;Interger i = new Integer(5);byte b=7
Java arrays always start at index 1. | False
Which of the following statements accurately describes how variables are passed to methods? | Arguments that are primitve type are passed by value
How do you change the value that is encapsulated by a wrapper class after you have instan-tiated it? | None of the above:setXXX(),Parse,equals
Suppose you are writing a class that provides custom deserialization. The class implements java.io.Serializable (and not java.io.Externalizable). What method should imple- ment the custom deserialization, and what is its access mode? | private readObject
Choose the valid identifiers from those listed here. | BigOlLongString,$int,bytes,$1,finalist
Which of the following signatures are valid for the main() method entry point of an application? | public static void main(String arg[]),(String args[])
If all three top-level elements occur in a source file, they must appear in which order? | Package declaration,imports,class/interface/enum definitions.
int[] x = new int[25]; | x[24] is 0,x.length is 25
is a set of java API for executing SQL statements. | JDBC
method is used to wait for a client to initiate communications. | accept()
drivers that are written partly in the Java programming language and partly in native code. These drivers use a native client library specific to the data source to which they connect. Again, because of the native code, their portability is limited. | Type 2
drivers that are pure Java and implement the network protocol for a specific data source. The client connects directly to the data source. | Type 4
drivers that use a pure Java client and communicate with a middleware server using a database-independent protocol. The middleware server then communicates the client's requests to the data source. | Type 3
drivers that implement the JDBC API as a mapping to another data access API, such as ODBC. Drivers of this type are generally ependent on a native library, which limits their portability. | Type 1
x = 32 (31 - 10 3); | 32
Which of the following statements accurately describes how variables are passed to methods? | Arguments that are primitive type are passed by value.
A signed data type has an equal number of non-zero positive and negative values available. | False
What is the range of values that can be assigned to a variable of type short? | -215 through 215 - 1
What is the range of values that can be assigned to a variable of type byte? | -27 through 27 - 1
Suppose a source file contains a large number of import statements. How do the imports affect the time required to compile the source file? | Compilation takes slightly more time.
Suppose a source file contains a large number of import statements and one class definition. How do the imports affect the time required to load the class? | Class loading takes no additional time.
Which of the following are legal import statements? | import java.util.Vector;import static java.util.Vector.*;
Which of the following may be statically imported? | Static method names,Method-local variable names
Which of the following are legal? | int c = 0xabcd;int d = 0XABCD;
Which of the following are legal? | double d = 1.2d;double d = 1.2D;
Which of the following are legal? | char c = '\u1234';
int x, a = 6, b = 7; x = a++ + b++; | x = 13, a = 7, b = 8
Which of the following expressions are legal? | int x = 6; if (!(x > 3)) {};int x = 6; x = ~x;
Which of the following expressions results in a positive value in x? | int x = -1; x = x >>> 5;
Which of the following expressions are legal? | String x = "Hello"; int y = 9; x += y;String x = "Hello"; int y = 9; x = x + y;
What is -8 % 5? | -3
What is 7 % -4? | 3
What results from running the following code?public class Xor {public static void main(String args[]) {byte b = 10; // 00001010 binary byte c = 15; // 00001111 binary b = (byte)(b ^ c);System.out.println("b contains " + b);}} | The output: b contains 5
What results from attempting to compile and run the following code?public class Conditional {public static void main(String args[]) {int x = 4;System.out.println("value is " +((x > 4) ? 99.99 : 9));}} | The output: value is 9.0
What does the following code do?Integer i = null;if (i != null & i.intValue() == 5) System.out.println("Value is 5"); | Throws an exception.
Is it possible to define a class called Thing so that the following method can return true under certain circumstances?boolean weird(Thing s) { Integer x = new Integer(5); return s.equals(x);} | Yes
Suppose ob1 and ob2 are references to instances of java.lang.Object. If (ob1 == ob2) is false, can ob1.equals(ob2) ever be true? | No
When a byte is added to a char, what is the type of the result? | int
When a short is added to a float, what is the type of the result? | float
Which statement is true about the following method?int selfXor(int i) { return i ^ i;} | It always returns 0.
What is the return type of the instanceof operator? | A boolean
Which of the following may appear on the left-hand side of an instanceof operator? | A reference
Which of the following may appear on the right-hand side of an instanceof operator? | A class;An interface
What is -50 >> 1? | -25
Which of the following declarations are illegal? | default String s;public final;abstract final double hyperbolicCosine();
Which of the following statements is true? | A final class may not have any abstract methods.
Which of the following statements is true? | Transient variables are not serialized.
Which modifier or modifiers should be used to denote a variable that should not be written out as part of its class's persistent state? | transient
Suppose class Supe, in package packagea, has a method called doSomething(). Suppose class Subby, in package packageb, overrides doSomething(). What access modes may Subby's version of the method have? | public;protected
Suppose interface Inty defines five methods. Suppose class Classy declares that it implements Inty but does not provide implementations for any of the five interface methods. Which is/are true? | The class will compile;The class may not be instantiated.
Which of the following may be declared final? | Classes;Data;Methods
Which of the following may follow the static keyword? | Data;Methods;Code blocks enclosed in curly brackets
Suppose class A has a method called doSomething(), with default access. Suppose class B extends A and overrides doSomething(). Which access modes may apply to B's version of doSomething()? | public;protected;Default
True or false: If class Y extends class X, the two classes are in different packages, and class X has a protected method called abby(), then any instance of Y may call the abby() method of any other instance of Y. | False
Which of the following statements are true? | A final class may not be extended.
What does the following code print?public class A{static int x;public static void main(String[] args) { A that1 = new A();A that2 = new A(); that1.x = 5; that2.x = 1000;x = -1; System.out.println(x);}} | 1000
Which of the following statements is correct? | Both primitives and object references can be both converted and cast.
Which one line in the following code will not compile?byte b = 5;char c = '5';short s = 55;int i = 555;float f = 555.5f;b = s;i = c;if (f > b) f = i; | Line 6
In the following code, what are the possible types for variable result? byte b = 11;short s = 13;result = b * ++s; | int, long, float, double
Consider the following class:class Cruncher {void crunch(int i) {System.out.println("int version");}void crunch(String s) {System.out.println("String version");} 8.public static void main(String args[]) {Cruncher crun = new Cruncher();char ch = 'p';crun.crunch(ch);}} | The code will compile and produce the following output: int version.
Which of the following statements is true? | Object references can be converted in both method calls and assignments, and the rules governing these conversions are identical.
Consider the following code. Which line will not compile?Object ob = new Object();String[] stringarr = new String[50];Float floater = new Float(3.14f);ob = stringarr;ob = stringarr[5];floater = ob;ob = floater; | Line 6
Consider the following code: Cat sunflower;Washer wawa;SwampThing pogo;sunflower = new Cat();wawa = sunflower;pogo = (SwampThing)wawa; | The code will compile but will throw an exception at line 7, because the runtime class of wawa cannot be converted to type SwamThing.
Consider the following code: Raccoon rocky;SwampThing pogo;Washer w;rocky = new Raccoon();w = rocky;pogo = w; | Line 7 will not compile; an explicit cast is required to convert a Washer to a SwampThing.
Which of the following may legally appear as the new type (between the parentheses) in a cast operation? | All of the above
Suppose the declared type of x is a class, and the declared type of y is an interface. When is the assignment x = y; legal? | When the type of x is Object
Which of the following may legally appear as the new type (between the parentheses) in a cast operation? | All: Abstract,Final,Primitives
Suppose the type of xarr is an array of XXX, and the type of yarr is an array of YYY. When is the assignment xarr = yarr; legal? | Sometimes
When is x & y an int? (Choose one). | Sometimes
What are the legal types for whatsMyType?short s = 10; whatsMyType = !s; | There are no possible legal types.
When a negative long is cast to a byte, what are the possible values of the result? | All:Positive,Zero,Negative
Which of the following operators can perform promotion on their operands? | + - ~
What is the difference between the rules for method-call conversion and the rules for assignment conversion? | There is no difference; the rules are the same.
is a set of java API for executing SQL statements | JDBC
method is used to wait for a client to initiate communications | accept()
drivers that are written partly in the Java programming language and partly in native code. These drivers use a native client library specific to the data source to which they connect | Type 2
drivers that are pure Java and implement the network protocol for a specific data source. The client connects directly to the data source | Type 4
drivers that use a pure Java client and communicate with a middleware server using a database-independent protocol. The middleware server then communicates the client's requests to the data source | Type 3
drivers that implement the JDBC API as a mapping to another data access API, such as ODBC. Drivers of this type are generally dependent on a native library, which limits their portability | Type 1
System.out.println(a.doit(4, 5)) | Line 26 prints a to System.out
Which two are true if a NullPointerException is thrown on line 3 of class C | code on line 29, The exception
What lines are output if the constructor at line 3 throws a MalformedURLException | Bad URL, Doing finally, Carrying
What lines are output if the methods at lines 3 and 5 complete successfully without throwing any exceptions | Success, Doing, Carrying
If lines 24, 25 and 26 were removed, the code would compile and the output would be 1 | 3.The code, would be 1, 2
An exception is thrown at runtime | An exception
first second first third snootchy 420 | third second first snootchy 420
dialog prevents user input to other windows in the application unitl the dialog is closed | Modal
You would like to write code to read back the data from this file. Which solutions will work | 2.FileInputStream, RandomAccessFile
A Java monitor must either extend Thread or implement Runnable | F
A monitor called mon has 10 threads in its waiting pool; all these waiting threads have the same priority. One of the threads is thr1 | You cannot specify
A programmer needs to create a logging method that can accept an arbitrary number of arguments. For example, it may be called in these ways | public void logIt(String... msgs)
A signed data type has an equal number of non-zero positive and negative values available | F
A thread wants to make a second thread ineligible for execution. To do this, the first thread can call the yield() method on the second thread | F
catch (InterruptedException e) | running some time
object is used to submit a query to a database | Statement
object is uses to obtain a Connection to a Database | DriverManager
After execution of the following code fragment, what are the values of the variables x, a, and b | x13, a7, b8
Yen and Euro both return correct Country value | 2.Euro returns, error at line 25
BigOlLongStringWithMeaninglessName | tick all
Compilation of class A will fail. Compilation of class B will succeed | B fail, A succeed
Line 46 will compile if enclosed in a try block, where TestException is caught | 2.if the enclosing, is caught
Holder h = new Holder() | 101
Decrementer dec = new Decrementer() | 12.3
Test t = (new Base()).new Test(1) | 2.new Test(1), new Test(1, 2)
Base(int j, int k, int l) | 2.Base(), Base(int j, int k)
Line 12 will not compile, because no version of crunch() takes a char argument | output: int version
output results when the main method of the class Sub is run | Value 5 This value 6
Float floater = new Float(3.14f) | Line 6
The application must be run with the -enableassertions flag or another assertionenabling flag | dai nhat, one or more
After line 3 executes, the StringBuffer object is eligible for garbage collection | line 2 executes..collection
The code will compile but will throw an exception at line 7, because runtime conversion from an interface to a class is not permitted | type SwampThing
The code will compile and run, but the cast in line 6 is not required and can be eliminated | The code will compile and run
for (int i = 0; i < 2; i++) | 4.i0,j12 - i1,j02
outer: for (int i = 0; i < 2; i++) | i = 1 j = 0
The code will compile but will throw an exception at line 7, because runtime conversion from an interface to a class is not permitted | Line 7 will not compile
int[] x = new int[25] | 2.x[24]=0, x.length is 25
public float aMethod(float a, float b) throws Exception | int a,b float p,q
public float aMethod(float a, float b, int c) throws Exception | 3.int a,b. float a,b-int c. private
Given a string constructed by calling s = new String("xyzzy"), which of the calls modifies the string | None of the above
Given arrays a1 and a2, which call returns true if a1 and a2 have the same length, and a1[i].equals(a2[i]) for every legal index i | Arrays.equals(a1, a2)
Assuming the class does not perform custom serialization, which fields are written when an instance of Xyz is serialized | 3.Public, Private, Volatile
can legally be placed before aMethod() on line 3 and be placed before aMethod() on line 8 | 3: private; 8: protected
NUTMEG, CINNAMON, CORIANDER, ROSEMARY | 3.Spice sp, Spice, String
List<String> names = new ArrayList<String>() | 2.Iterator, for
Compilation fails because of an error in line 15 | error in line 19
1 2 3 | 2 3
public interface B inheritsFrom A | B extends A
protected double getSalesAmount() { return 1230.45; } | 2.public, protected
Line 16 creates a directory named �d� and a file �f� within it in the file system | 3.An exception, Line 13, line 14
Nav.Direction d = Nav.Direction.NORTH | Nav.Direction.NORTH
new class Foo { public int bar() { return 1; } } | new Foo()
IllegalArgumentException | StackOverflowError
Circle c = new Circle(); c.Shape.setAnchor(10,10); c.Shape.draw() | Shape s = new Circle...s.draw()
Compilation fails because of an error in line 12 | 1 2 3
NullPointerException | Compilation fails
A NumberFormatException is thrown by the parse method at runtime | Compilation fails
An exception is thrown at runtime | Compilation fails
passed An AssertionException is thrown without the word �stuff� added to the stack trace | An AssertionError...with the
collie | collie harrier
doStuff x = 6 main x = 6 | doStuff x =5 main x =5
The setCardlnformation method breaks encapsulation | The ownerName
The value of all four objects prints in natural order | Compilation fails...line 29
The code on line 33 executes successfully | 3.33 throws, 35 throws, 33 executes
What is the result if a NullPointerException occurs on line 34 | ac
Compilation will fail because of an error in line 55 | Line 57...value 3
java -ea test file1 file2 | 2.java -ea test, dai nhat
String s = �123456789�; s = (s-�123�).replace(1,3,�24�) - �89� | 2.delete(4,6), delete(2,5).insert( 1, �24�)
The Point class cannot be instatiated at line 15 | Line.Point p = new Line.Point()
for( int i=0; i< x.length; i++ ) System.out.println(x[i]) | 2.for(int z : x), dai nhat
int MY_VALUE = 10 | 3.final, static, public
Compilation fails because of an error in line: public void process() throws RuntimeException | A Exception
How can you ensure that multithreaded code does not deadlock | There is no single
How can you force garbage collection of an object | Garbage collection
How do you prevent shared data from being corrupted in a multithreaded environment | Access the variables
How do you use the File class to list the contents of a directory | String[] contents
The number of bytes depends on the underlying system | 8
How many locks does an object have | One
If all three top-level elements occur in a source file, they must appear in which order | Package declaration, imports
the two classes are in different packages, and class X has a protected method called abby(), then any instance of Y may call the abby() method of any | F
TestThread3 ttt = new TestThread3 | Y
If you need a Set implementation that provides value-ordered iteration, which class should you use | TreeSet
In order for objects in a List to be sorted, those objects must implement which interface and method | Comparable...compareTo
after execution of line 1, sbuf references an instance of the StringBuffer class. After execution of line 2, sbuf still references the same instance | T
what are the possible types for variable result | int, long, float, double
helps manage the connection between a Java program and a database | Connection
Is it possible to define a class called Thing so that the following method can return true under certain circumstances | Y
Is it possible to write code that can execute only if the current thread owns multiple locks | Y
JDBC supports ______ and ______ models | Two-tier and three-tier
MVC is short call of | Model-View-Controller
No output because of compile error at line: System.out.println("b="+b) | b = b * b1
Object ob2= new Object() | Have a nice day
Object ob2= ob1 | ob1 equals ob2, ob1==ob2
String s2 = "xyz" | Line 4, Line 6
String s2 = new String("xyz") | Line 6
String s2 = new String(s1) | Line 6
Select correct statement about RMI | All the above
Select correct statement(s) about remote class | All the others choices
Select correct statements about remote interface | All the others choices
Select INCORRECT statement about serialization | When an Object Output
Select INCORRECT statement about deserialize | We use readObject
Select incorrect statement about RMI server | A client accesses
Select incorrect statement about ServerSocket class | To make the new object
Select incorrect statement about Socket class | server through UDP
Select the correct statement about JDBC two-tier processing model | A user's commands
SQL keyword ___ is followed by the selection criteria that specify the rows to select in a query | WHERE
Statement objects return SQL query results as | ResultSet
When a JDBC connection is created, it is in auto-commit mode | Both 1 and 2 are true
Suppose a method called finallyTest() consists of a try block, followed by a catch block, followed by a finally block | If the JVM doesn't crash
Suppose a source file contains a large number of import statements and one class definition. How do the imports affect the time required to load the class | no additional time
Suppose a source file contains a large number of import statements. How do the imports affect the time required to compile the source file | slightly more time
Suppose class A extends Object; Class B extends A; and class C extends B. Of these, only class C implements java.io.Externalizable | C must have a
Suppose class A extends Object; class B extends A; and class C extends B. Of these, only class C implements java.io.Serializable | B must have a
Suppose class A has a method called doSomething(), with default access. Suppose class B extends A and overrides doSomething() | private
Suppose class Supe, in package packagea, has a method called doSomething(). Suppose class Subby, in package packageb, overrides doSomething() | 2.public, protected
void doSomething(int a, float b) | public...(int a, float b)
Suppose interface Inty defines five methods. Suppose class Classy declares that it implements Inty but does not provide implementations for any of the five interface methods | 2.declared abstract, may not be
Suppose prim is an int and wrapped is an Integer. Which of the following are legal Java statements | All the above
Suppose salaries is an array containing floats. Which of the following are valid loop control statements for processing each element of salaries | for (float f:salaries)
Suppose the declared type of x is a class, and the declared type of y is an interface. When is the assignment x = y; legal | When the...x is Object
Suppose the type of xarr is an array of XXX, and the type of yarr is an array of YYY. When is the assignment xarr = yarr; legal | Sometimes
Suppose x and y are of type TrafficLightState, which is an enum. What is the best way to test whether x and y refer to the same constant | if (x == y)
Suppose you are writing a class that will provide custom deserialization. What access mode should the readObject() method have | private
Suppose you are writing a class that will provide custom serialization. What access mode should the writeObject() method have | private
Suppose you want to create a custom thread class by extending java.lang.Thread in order to provide some special functionality | Override run()
Suppose you want to write a class that offers static methods to compute hyperbolic trigonometric functions. You decide to subclass java.lang.Math and provide the new functionality as a set of static methods | subclass java.lang.Math
Swing components cannot be combined with AWT components | T
class is the primary class that has the driver information | DriverManager
class is used to implement a pull-down menu that provides a number of items to select from | Menu
The element method alters the contents of a Queue | F
The Swing component classes can be found in the | javax.swing
There are two classes in Java to enable communication using datagrams namely | DataPacket and DataSocket
Compilation of Parrot.java fails at line 7 because method getRefCount() is static in the superclass, and static methods may not be overridden to be nonstatic | dai nhat: nonstatic
Compilation of Nightingale will succeed, but an exception will be thrown at line 10, because method fly() is protected in the superclass | The program...After: 2
void doSomething() throws IOException, EOFException | ngan-dai nhat, throws EOFException
URL referring to databases use the form | protocol:subprotocol:datasoursename
What are the legal types for whatsMyType | There are no possible legal types
What does the following code do | Throws an exception
There is no output because the code throws an exception at line 1 | output is i = 20
1000 | -1
What happens when you try to compile and run the following application | thrown at line 9
The code compiles, and prints out >>null<< | out >>null<<
An exception is thrown at line 6 | thrown at line 7
What is -50 >> 2 | -13
What is 7 % -4 | 3
What is -8 % 5 | -3
What is the difference between the rules for method-call conversion and the rules for assignment conversion | There is no difference
The code will compile as is. No modification is needed | On line 1, remove
What is the range of values that can be assigned to a variable of type byte | ?2mu7 through 2mu7 ? 1
What is the range of values that can be assigned to a variable of type short | ?2mu15 through
The code compiles and executes; afterward, the current working directory contains a file called datafile | The code fails to compile
What is the return type of the instanceof operator | A boolean
What method of the java.io.File class can create a file on the hard drive | createNewFile()
The output: value is 99.99 | value is 9.0
The output: b contains 250 | b contains 5
What would be the output from this code fragment | message four
When a byte is added to a char, what is the type of the result | int
When a negative byte is cast to a long, what are the possible values of the result | Negative
When a negative long is cast to a byte, what are the possible values of the result | All the above
When a short is added to a float, what is the type of the result | float
When comparing java.io.BufferedWriter to java.io.FileWriter, which capability exists as a method in only one of the two | writing a line
When does an exception's stack trace get recorded in the exception object | is constructed
When is it appropriate to pass a cause to an exception's constructor | in response to catching
When is it appropriate to write code that constructs and throws an error | Never
When is x & y an int | Sometimes
When the user attempts to close the frame window, _______ event in generated | window closing
When the user selects a menu item, _______ event is generated | Action event
Java programming language, the compiler converts the human-readable source file into platform-independent code that a Java Virtual Machine can understand | bytecode
Whenever a method does not want to handle exceptions using the try block, the | throws
Which are the correct statements used for getting connection object to connect to SQL Server database | String url =jdbc:odbc
Which class and static method can you use to convert an array to a List | Arrays.asList
Which is four-step approach to help you organize your GUI thinking | Identify, Isolate, Sketch
Which is the four steps are used in working with JDBC | Connect, Create, Look
Which JDBC processing model that requires a JDBC driver that can communicate with the particular data source being accessed | two-tier
Which line of code tells a scanner called sc to use a single digit as a delimiter | sc.useDelimiter("\\d")
Man has the best friend who is a Dog | private Dog bestFriend
Which methods return an enum constant�s name | 2.name(), toString()
Which modifier or modifiers should be used to denote a variable that should not be written out as part of its class's persistent state | transient
Which of the following are legal argument types for a switch statement | 3.byte, int, char
Which of the following are legal enums | 3.ngan-dai nhat, lion int weight
Which of the following are legal import statements | 2.import...Vector, Vector.*
Which of the following are legal loop constructions | for (int k=0, j+k != 10; j++,k++)
Which of the following are legal loop definitions | None of the above
double d = 1.2d5 | 2.double d = 1.2d, 1.2D
int d = 0XABCD | 2.int c = 0xabcd, dai nhat
char c = 0x1234 | 2.0x.., '\u1234'
Vector <String> theVec = new Vector<String>() | 2.List...<String>(), dai nhat
Which of the following are methods of the java.util.SortedMap interface | headMap, tailMap, subMap
Which of the following are methods of the java.util.SortedSet interface | All the above
System.out has a println() method | All the above
The JVM runs until there is only one non-daemon thread | are no non-daemon
When an application begins running, there is one non-daemon thread, whose job is to execute main() | 3.nhat, thread, non-daemon thread
When you declare a block of code inside a method to be synchronized, you can specify the object on whose lock the block should synchronize | 2.the method always, nhat
An enum definition should declare that it extends java.lang.Enum | 2.contain public, private
Primitives are passed by reference | 2.by value
An anonymous inner class that implements several interfaces may extend a parent class other than Object | implement at most, class may extend
Which of the following are valid arguments to the DataInputStream constructor | FileInputStream
Which of the following are valid mode strings for the RandomAccessFile constructor | All the above
Which of the following calls may be made from a non-static synchronized method | All the above
Which of the following classes implement java.util.List | 2.ArrayList, Stack
Which of the following classes implements a FIFO Queue | LinkedList
Which of the following declarations are illegal | 3.ngan-dai nhat, double d
int x = 6; if (!(x > 3)) | 2.dai nhat, x = ~x
String x = "Hello"; int y = 9; if (x == y) | 2.ngan nhat, x=x+y
Which of the following expressions results in a positive value in x | int x = �1; x = x >>> 5
Which of the following interfaces does not allow duplicate objects | Set
Which of the following is not appropriate situations for assertions | Preconditions of a public method
Which of the following is NOTa valid comment | /* comment
Which of the following is the most appropriate way to handle invalid arguments in a public method | IllegalArgumentException
Readers have methods that can read and return floats and doubles | None of the above
An enum definition may contain the main() method of an application | All the above
Which of the following may appear on the left-hand side of an instanceof operator | A reference
Which of the following may appear on the right-hand side of an instanceof operator | 2.A class, An interface
Which of the following may be declared final | 2.Classes, Methods
Which of the following may be statically imported | 2.Static method, Static field
Which of the following may follow the static keyword | 3.Data, Methods, Code blocks
Which of the following may legally appear as the new type (between the parentheses) in a cast operation | All of
Which of the following may not be synchronized | Classes
Which of the following may override a method whose signature is void xyz(float f) | 2.void, public void xyz(float f)
Which of the following methods in the Thread class are deprecated | suspend() and resume()
Which of the following operations might throw an ArithmeticException | None of
Which of the following operators can perform promotion on their operands | 3.cong, tru, xap xi
Which of the following restrictions apply to anonymous inner classes | must be defined
Which of the following should always be caught | Checked exceptions
Which of the following signatures are valid for the main() method entry point of an application | 2.static void...(String arg[])
Which of the following statements about the wait() and notify() methods is true | calls wait() goes into
Which of the following statements about threads is true | Threads inherit their
A final class may not contain non-final data fields | may not be extended
An abstract class must declare that it implements an interface | None
An abstract class may not have any final methods | Only statement 2
Only object references are converted automatically; to change the type of a primitive, you have to do a cast | Both primitives
Transient methods may not be overridden | variables are not
Object references can be converted in both method calls and assignments, but the rules governing these conversions are very different | conversions are identical
Bytecode characters are all 16 bits | Unicode characters
To change the current working directory, call the changeWorkingDirectory() method of the File class | None
When you construct an instance of File, if you do not use the file-naming semantics of the local machine, the constructor will throw an IOException | None
When the application is run, thread hp1 will execute to completion, thread hp2 will execute to completion, then thread hp3 will execute to completion | None of
Compilation succeeds, although the import on line 1 is not necessary. During execution, an exception is thrown at line 3 | fails at line 2
Compilation fails at line 1 because the String constructor must be called explicitly | succeeds. No exception
Line 4 executes and line 6 does not | Line 6 executes
There will be a compiler error, because class Greebo does not correctly implement the Runnable interface | Runnable interface
The acceptable types for the variable j, as the argument to the switch() construct, could be any of byte, short, int, or long | value is three
The returned value varies depending on the argument | returns 0
Lines 5 and 12 will not compile because the method names and return types are missing | output x = 3
Line 13 will not compile because it is a static reference to a private variable | output is x = 104
Which statements about JDBC are NOT true | 2.database system, DBMS
Which two code fragments correctly create and initialize a static array of int elements | 2.a = { 100,200 }, static
Which two of the following interfaces are at the top of the hierarchies in the Java Collections Framework | 2.Map, Collection
A new directory called dirname and a new file called filename are created, both in the current working directory | No directory
protected class Cat extends Owner | public class Cat extends Pet
Date vaccinationDue | 2.boolean, String
What is -15 % -10 | -5
command line on a Windows system | 2.must contain the statement, the file
The string created on line 2 does not become eligible for garbage collection in this code | After line 3
When the application runs, what are the values of n and w.x after the call to bump() in the main | n is 10, w.x is 11
The addAll() method of that interface takes a single argument, which is a reference to a collection whose elements are compatible with E. What is the declaration of the addAll() method | addAll(Collection<? extends E> c)
If you want a vector in which you know you will only store strings, what are the advantages of using fancyVec rather than plainVec | Attempting to...compiler error
When should objects stored in a Set implement the java.util.Comparable interface | Set is a TreeSet
What relationship does the extends keyword represent | is a
class bbb.Bbb, which extends aaa.AAA, wants to override callMe(). Which access modes for callMe() in aaa.AAA will allow this | 2.public, protected
Lemon lem = new Lemon(); Citrus cit = new Citrus() | 3.cit = lem, cit=(Citrus), lem=(lemon)
it also has a method called chopWoodAndCarryWater(), which just calls the other two methods | inappropriate cohesion, inappropriate coupling
sharedOb.wait() | 2.aThread.interrupt, sharedOb.notifyAll
line prints double d in a left-justified field that is 20 characters wide, with 15 characters to the right of the decimal point | System.out.format("%-20.15f", d)
What code at line 3 produces the following output | String delim = �\\d+�
How do you generate a string representing the value of a float f in a format appropriate for a locale loc | NumberFormat.getInstance(loc)
you want to use a DateFormat to format an instance of Date. What factors influence the string returned by DateFormat�s format() method | 2.LONG, or FULL, The locale
you want to create a class that compiles and can be serialized and deserialized without causing an exception to be thrown. Which statements are true regarding the class | 2.dai nhat, ngan nhat
you are writing a class that will provide custom deserialization. The class implements java.io.Serializable (not java.io.Externalizable) | private
What interfaces can be implemented in order to create a class that can be serialized | 2.dai nhat, ngan nhat
The file contains lines of 8-bit text, and the 8-bit encoding represents the local character set, as represented by the cur- rent default locale. The lines are separated by newline characters | FileReader instance
shorty is a short and wrapped is a Short | all
How is IllegalArgumentException used | 2.certain methods, public methods
While testing some code that you are developing, you notice that an ArrayIndexOutOf- BoundsException is thrown. What is the appropriate reaction | None
Which lines check that x is equal to four? Assume assertions are enabled at compile time and runtime | 2.assert x == 4
int[] ages = { 9, 41, 49 }; int sum = 0 | 2.i<ages.length, for (int i:ages)
Which of the following types are legal arguments of a switch statement | enums, bytes
class A extends java.util.Vector { private A(int x) | does not create a default
void callMe(String� names) | method, names is an array
Given a class with a public variable theTint of type Color, which of the following methods are consistent with the JavaBeans naming standards | public Color getTheTint()
are valid arguments to the DataInputStream constructor | FileInputStream
are valid mode strings for the RandomAccessFile constructor | r, rw, rws, rwd
method of the java.io.File class can create a file on the hard drive | createNewFile()
class A extends Object; Class B extends A; and class C extends B. Of these, only class C implements java.io.Externalizable | C must have
class A extends Object; class B extends A; and class C extends B. Of these, only class C implements java.io.Serializable | B must have
you are writing a class that will provide custom serialization. The class implements java.io.Serializable (not java.io.Externalizable) | private
How do you use the File class to list the contents of a directory | String[] contents = myFile.list();
call returns true if a1 and a2 have the same length, and a1[i].equals(a2[i]) for every legal index i | java.util.Arrays.equals(a1, a2)
line of code tells a scanner called sc to use a single digit as a delimiter | sc.useDelimiter(�\\d�)
you want to write a class that offers static methods to compute hyperbolic trigonometric functions. You decide to subclass java.lang.Math and provide the new functionality as a set of static methods | java.lang.Math
Given a string constructed by calling s = new String(�xyzzy�), which of the calls modifies the string | none
Suppose you want to create a custom thread class by extending java.lang.Thread in order to provide some special functionality. Which of the following must you do | Override run()
you prevent shared data from being corrupted in a multithreaded environment | Access the variables
Is it possible to write code that can execute only if the current thread owns multiple locks | yes
statements about the wait() and notify() methods is true | pool of waiting threads
methods in the Thread class are deprecated | suspend() and resume()
A Java monitor must either extend Thread or implement Runnable | F
One of the threads is thr1. How can you notify thr1 so that it alone moves from the Waiting state to the Ready state | You cannot specify
A thread wants to make a second thread ineligible for execution. To do this, the first thread can call the yield() method on the second thread | F
Which methods return an enum constant�s name | name(), toString()
restrictions apply to anonymous inner classes | inside a code block
A pet has an owner, a registration date, and a vaccination-due date. A cat is a pet that has a flag indicating whether it has been neutered, and a textual description of its markings | boolean, string
Which of the following are valid declarations? Assume java.util | 1Vector 2Set 3Map string,string
You can determine all the keys in a Map in which of the following ways | Set object from the Map
What keyword is used to prevent an object from being serialized | transient
abstract class can contain methods with declared bodies. | E. public, protected, default, private
access modifier allows you to access method calls in libraries not created in Java | native
Which of the following statements are true? (Select all that apply.) | object cannot reassigned
The keyword extends refers to what type of relationship | is a
keywords is used to invoke a method in the parent class | super
What is the value of x after the following operation is performed | 3
method call is used to tell a thread that it has the opportunity | notify()
Assertions are used to enforce all but which | Exceptions
force garbage collection by calling System.gc(). | B. False
Select the valid primitive data type | 1.boolean 2.char 3.float
How many bits does a float contain | 32
What is the value of x after the following line is executed | 32
StringBuffer is slower than a StringBuilder, but a StringBuffer | True
list of primitives ordered in smallest to largest bit size representation | D. char, int, float, long
Which class provides locale-sensitive text formatting for date and time information | java.text.DateFormat
int x = 9; byte b = x | False
Which of the following code snippets compile | 1.Integer 2.Integer 3.byte
Java arrays always start at index 1 | False
accurately describes how variables are passed to methods | that are primitive type are passed by value
change the value that is encapsulated by a wrapper class after you have instan | None of the above.
The class implements java.io.Serializable (and not java.io.Externalizable) | private readObject
A signed data type has an equal number of non-zero positive and negative values | False
signatures are valid for the main() method entry point of an application | public static void main(String[] args)
three top-level elements occur in a source file, they must appear | Package declaration, imports, class/interface/enum definitions
int[] x = new int[25] | x[24] is 0 and x.length is 25
How can you force garbage collection of an object | Garbage collection cannot be forced.
range of values that can be assigned to a variable of type short | -215 through 215 - 1
range of values that can be assigned to a variable of type byte | -27 through 27 - 1
How do the imports affect the time required to compile the source file | Compilation takes slightly more time
How do the imports affect the time required to load the class? | Class loading takes no additional time
legal import statements | 1.import java.util.Vector 2.import static java.util.Vector
may be statically imported | 1.Static method names 2.Static field names
ob1 == ob2 | No
When a byte is added to a char | int
When a short is added to a float | float
ArithmeticException | 1.None of these 2./
What is the return type of the instanceof operator | boolean
may appear on the left-hand side of an instanceof operator | reference
may appear on the right-hand side of an instanceof operator | class and interface
What is -50 >> 1 | -25
A final class may not have any abstract methods | true
denote a variable that should not be written out as part of its class�s persistent state | transient
may legally appear as the new type (between the parentheses) in a cast operation | All of the above
type of x is a class, and the declared type of y is an interface. When is the assignment x = y | When the type of x is Object
xarr is an array of XXX, and the type of yarr is an array of YYY | Sometimes
When is x & y an int | Sometimes
negative long is cast to a byte | All of the above
negative byte is cast to a long | Negative
operators can perform promotion on their operands | + - ~(nga)
difference between the rules for method-call conversion and the rules for assignment conversion | There is no difference
Which of the following are appropriate situations for assertions | DAP AN SAI : Preconditions of a public method
appropriate way to handle invalid arguments in a public method | IllegalArgumentException
Suppose salaries is an array containing floats | for (float f:salaries)
Suppose a method called finallyTest() consists of a try block | If the JVM doesn�t crash and
appropriate to pass a cause to an exception�s constructor | thrown in response to catching of a different exception type
When does an exception�s stack trace get recorded in the exception object | is constructed
Which of the following is illegal statement? | float f=1.01;
You want to find out the value of the last element of an array. You write the following code. What will happen when you compile and run it.?public class MyAr{public static void main(String argv[]){int[] i = new int[5];System.out.println(i[5]);}} | An error at run time
What is the return type of the instanceof operator? | A Boolean
Which of the following statements is true? | A class that has one abstract method must be abstract class
What is the difference between yielding and sleeping? | When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.
A____dialog prevents user input to other windows in the application unitl the dialog is closed. | Modal
A Java monitor must either extend Thread or implement Runnable. | False
A monitor called mon has 10 threads in its waiting pool; all these waiting threads have the same priority. One of the threads is thr1. How can you notify thr1 so that it alone moves from the Waiting state to the Ready state? | You cannot specify which thread will get notified.
A thread wants to make a second thread ineligible for execution. To do this, the first thread can call the yield() method on the second thread. | False
A(n)____object is used to submit a query to a database | Statement
A(n)____object is uses to obtain a Connection to a Database | DriverManager
Given a string constructed by calling s = new String("xyzzy"), which of the calls modifies the string? | None of the above
Given arrays a1 and a2, which call returns true if a1 and a2 have the same length, and a1[i].equals(a2[i]) for every legal index i? | java.util.Arrays.equals(a1, a2);
public class Xyz implements java.io.Serializable | iAmPublic;iAmPrivate;iAmVolatile
Given the following code, and making no other changes, which combination of access modifiers (public, protected, or private) can legally be placed before aMethod() on line 3 and be placed before aMethod() on line 8? | line 3: private; line 8: protected
Given the following code, which of the following will compile? (Choose three.)enum Spice { NUTMEG, CINNAMON, CORIANDER, ROSEMARY; } | 3 cai dai nhat
List<String> names = new ArrayList<String>(); | Iterator<String> iter = names.iterator();for (String s:names)
String DEFAULT_GREETING = �Hello World�; | public interface B extends A { }
protected abstract double getSalesAmount(); | public;protected
File file = new File(directory,�f�); | An exception is thrown at runtime;File object named �d.�;Line 14 creates a File object named �f.�
public enum Direction { NORTH, SOUTH, EAST, WEST } | Nav.Direction d = Nav.Direction.NORTH;
public int fubar( Foo foo) { return foo.bar(); } | new Foo() { public int bar(){return 1; } }
ClassA a = new ClassA(); | StackOverflowError
public void setAnchor(int x, int y) { | Shape s = new Circle(); s.setAnchor(10,10); s.draw();
for (int i: someArray) System.out.print(i +" "); | 1 2 3
System.out.println(�NullPointerException�); | Compilation fails.
} catch (NumberFormatException nfe) { | Compilation fails.
System.out.println(tokens.length); | Compilation fails.
System.out.print(�collie �); | collie harrier
System.out.print("doStuff x = "+ x++); | doStuff x = 5 main x = 5
public void setCardlnformation(String cardlD,String ownerName,Integer limit) | The ownerName variable breaks encapsulation.
java.util.Array.sort(myObjects); | Compilation fails due to an error in line 29.
int []x= {1, 2,3,4, 5}; | Line 57 will print the value 3.
public static class Point { } | Line.Point p = new Line.Point();
static void foo(int...x) { | for(int z : x) System.out.println(z);for( int i=0; i< x.length; i++ ) System.out.println(x[i]);
public interface Status { | final;static;public
if (true) throw new RuntimeException(); System.out.print("B"); | A Exception
How can you ensure that multithreaded code does not deadlock? | There is no single technique that can guarantee non-deadlocking code.
How can you force garbage collection of an object? | Garbage collection cannot be forced.
How do you prevent shared data from being corrupted in a multithreaded environment? | Access the variables only via synchronized methods.
How do you use the File class to list the contents of a directory? | String[] contents = myFile.list();
dos.writeFloat(0.0001f); | 8
How many locks does an object have? | One
If all three top-level elements occur in a source file, they must appear in which order? | Package declaration, imports, class/interface/enum definitions.
If class Y extends class X, the two classes are in different packages, and class X has a protected method called abby(), then any instance of Y may call the abby() method of any other instance of Y. | False
ttt.start(); | yes
If you need a Set implementation that provides value-ordered iteration,which class should you use? | TreeSet
In order for objects in a List to be sorted, those objects must implement which interface and method? | Comparable interface and its compareTo method.
sbuf.insert("-University"); | True
sbuf.insert(3, "-University"); | True
result = b * ++s; | int, long, float, double
Interface____helps manage the connection between a Java program and a database. | Connection
boolean weird(Thing s) { Integer x = new Integer(5); return s.equals(x); | Yes
JDBC supports___and___models. | Two-tier and three-tier
byte b = 2; byte b1 = 3; b = b * b1; | No output because of compile error at line: b = b * b1;
System.out.println("Have a nice day!"); | Have a nice day!
String s2 = "xyz"; | Line 4;Line 6
String s2 = new String("xyz"); | Line 6
String s1 = "xyz"; | Line 6
s2=s2.intern(); | Line 4;Line 6
Select correct statement about RMI | All allow programmers;use object serialization;RMI applications
Select correct statement(s) about remote class | All It must extend;It must implement;It is the class
Select correct statements about remote interface. | A remote;All remote interfaces;All methods;The type of
Select INCORRECT statement about serialization | dai nhat
Select INCORRECT statement about deserialize. | We use readObject() method of ObjectOutputStream class to deserialize.
Select incorrect statement about RMI server. | A client accesses a remote object by specifying only the server name.
Select incorrect statement about ServerSocket class. | dai nhat
Select incorrect statement about Socket class | with a server through UDP.
Select the correct statement about JDBC two-tier processing model. | A user's commands are delivered to the database or other data source, and the results of those statements are sent back to the user.
SQL keyword____is followed by the selection criteria that specify the rows to select in a query | WHERE
Statement objects return SQL query results as____objects | ResultSet
Study the statements: 1)When a JDBC connection is created, it is in auto-commit mode 2)Once auto-commit mode is disabled, no SQL statements will be committed until you call the method commit explicitly | Both 1 and 2 are true
Suppose a method called finallyTest() consists of a try block, followed by a catch block, followed by a finally block. Assuming the JVM doesn�t crash and the code does not execute a System.exit() call, under what circumstances will the finally block not begin to execute? | If the JVM doesn't crash and the code does not execute a System.exit() call,the finally block will always execute.
Suppose class A extends Object; Class B extends A; and class C extends B.Of these, only class C implements java.io.Externalizable. Which of the following must be true in order to avoid an exception during deserialization of an instance of C? | C must have a no-args constructor.
Of these, only class C implements java.io.Serializable. Which of the following must be true in order to avoid an exception during deserialization of an instance of C? | B must have a no-args constructor.
Suppose class A has a method called doSomething(), with default access. Suppose class B extends A and overrides doSomething(). Which access modes may not apply to B�s version of doSomething()? | private
Suppose class Supe, in package packagea, has a method called doSomething(). Suppose class Subby, in package packageb, overrides doSomething(). What access modes may Subby�s version of the method have? | public;protected
void doSomething(int a, float b) { � } | public void doSomething(int a, float b) { � }
Suppose interface Inty defines five methods. Suppose class Classy declares that it implements Inty but does not provide implementations for any of the five interface methods. Which are true? | The class will compile if it is declared abstract;The class may not be instantiated.
Suppose prim is an int and wrapped is an Integer. Which of the following are legal Java statements? | All
Suppose salaries is an array containing floats. Which of the following are valid loop control statements for processing each element of salaries? | for (float f:salaries)
Suppose x and y are of type TrafficLightState, which is an enum. What is the best way to test whether x and y refer to the same constant? | if (x == y)
Suppose you are writing a class that will provide custom deserialization.The class implements java.io.Serializable (not java.io.Externalizable). What access mode should the readObject() method have? | private
Suppose you are writing a class that will provide custom serialization. The class implements java.io.Serializable (not java.io.Externalizable). What access mode should the writeObject() method have? | private
Suppose you want to create a custom thread class by extending java.lang.Thread in order to provide some special functionality. Which of the following must you do? | Override run().
Suppose you want to write a class that offers static methods to compute hyperbolic trigonometric functions. You decide to subclass java.lang.Math and provide the new functionality as a set of static methods. Which one statement is true about this strategy? | The strategy fails because you cannot add static methods to a subclass.
Swing components cannot be combined with AWT components. | True
The____class is the primary class that has the driver information. | DriverManager
The____class is used to implement a pull-down menu that provides a number of items to select from. | Menu
The element method alters the contents of a Queue. | False
The Swing component classes can be found in the package. | javax.swing
There are two classes in Java to enable communication using datagrams namely. | DataPacket and DataSocket
whatsMyType = !s; | There are no possible legal types.
What is the range of values that can be assigned to a variable of type byte? | -2^7 through 2^7 - 1
What is the range of values that can be assigned to a variable of type short? | -2^15 through 2^15 - 1
System.out.println("value is " + ((x > 4) ? 99.99 : 9)); | The output: value is 9.0
When a negative byte is cast to a long, what are the possible values of the result? | Negative
When a negative long is cast to a byte, what are the possible values of the result? | All
When comparing java.io.BufferedWriter to java.io.FileWriter, which capability exists as a method in only one of the two? | writing a line separator to the stream
When does an exception's stack trace get recorded in the exception object? | When the exception is constructed
When is it appropriate to pass a cause to an exception's constructor? | When the exception is being thrown in response to catching of a different exception type
When is it appropriate to write code that constructs and throws an error? | Never
When is x & y an int? | Sometimes
When the user attempts to close the frame window,_____event in generated. | window closing
When the user selects a menu item,_____event is generated. | Action event
When you compile a program written in the Java programming language,the compiler converts the human-readable source file into platform- independent code that a Java Virtual Machine can understand. What is this platform-independent code called? | Bytecode
Whenever a method does not want to handle exceptions using the try block, the____is used. | Throws
Which are the correct statements used for getting connection object to connect to SQL Server database? | String url ="jdbc:odbc:data_source_name"; Connection con = DriverManager.getConnection (url, �user", "password");
Which class and static method can you use to convert an array to a List? | Arrays.asList
Which is four-step approach to help you organize your GUI thinking. | Identify needed components.Isolate regions of behavior. Sketch the GUI.Choose layout managers.
Which is the four steps are used in working with JDBC? | 1)Connect2)Create3)Look4)Close
Which JDBC processing model that requires a JDBC driver that can communicate with the particular data source being accessed? | two-tier
Which line of code tells a scanner called sc to use a single digit as a delimiter? | sc.useDelimiter("\\d");
Which Man class properly represents the relationship "Man has the best friend who is a Dog"? | class Man { private Dog bestFriend; }
Which methods return an enum constant�s name? | name();toString()
Which modifier or modifiers should be used to denote a variable that should not be written out as part of its class's persistent state? | Transient
Which of the following are legal argument types for a switch statement? | Byte;Int;Char
Which of the following are legal enums? | enum Animals { LION, TIGER, BEAR }
Which of the following classes implement java.util.List? | ArrayList;Stack
Which of the following classes implements a FIFO Queue? | LinkedList
Which of the following interfaces does not allow duplicate objects? | Set
Which of the following is not appropriate situations for assertions? | Preconditions of a public method
Which of the following is the most appropriate way to handle invalid arguments in a public method? | Throw java.lang.IllegalArgumentException.
Which of the following may appear on the right-hand side of an instanceof operator? | A class; An interface
Which of the following may be declared final? | Classes;Methods
Which of the following may be statically imported? | Static method names;Static field names
Which of the following may not be synchronized? | Classes
Which of the following methods in the Thread class are deprecated? | suspend() and resume()
Which of the following operations might throw an ArithmeticException? | /
Which of the following restrictions apply to anonymous inner classes? | They must be defined inside a code block.
Which of the following should always be caught? | Checked exceptions
Which of the following statements about the wait() and notify() methods is true? | The thread that calls wait() goes into the monitor�s pool of waiting threads.
Which of the following statements about threads is true? | Threads inherit their priority from their parent thread.
Which of the following statements are true? 1)An abstract class may not have any final methods. 2)A final class may not have any abstract methods. | Only statement 2
Which of the following statements is true? | Object references can be converted in both method calls and assignments,and the rules governing these conversions are identical.
Unicode characters are all 16 bits. | True
StringBuffer s1 = new StringBuffer("FPT"); | Compilation succeeds. No exception is thrown during execution.
String s1 = "abc" + "def"; | Line 6 executes and line 4 does not.
Greebo g = new Greebo(); | There will be a compiler error, because class Greebo does not correctly implement the Runnable interface.
case 2 + 1: | The output would be the text value is two followed by the text value is three.
Which statements about JDBC are NOT true? | Java database;Java API for connecting
Which two of the following interfaces are at the top of the hierarchies in the Java Collections Framework? | Map;Collection
1. File f1 = new File("dirname"); | No directory is created, and no file is created.
int c = 0xabcd and int d = 0XABCD | 2 dap an
double d = 1.2d and double d = 1.2D | 2 dap an
char c = �\u1234� | 1 dap an
passed by value and passed by value | 2 dap an
int x = 6; if (!(x > 3)) and int x = 6; x = ~x | 2 dap an
int x = �1; x = x >>> 5 | 1 dap an
int y = 9; x += y; and int y = 9; x = x + y; | 2 dap an
default String s ,, abstract double d ,, double hyperbolic | 3 dap an
Both primitives and object references can be both converted and cast | dap an
and the rules governing these conversions are identical | dap an
When does an exception�s stack trace get recorded in the exception object | is constructed
You have been given a design document for a veterinary registration | String markings, boolean neutered
When an array is created, all elements are initialized with ___. | a fixed value that depends on the element type
What is the type of a variable that references an array of integers? | int[]
Which class manages a sequence of objects whose size can change? | ArrayList
What is the type of a variable that references an array list of strings? | ArrayList<String>
You access array list elements with an integer index, using the __________. | get method
The wrapper class for the primitive type double is ____________________. | Double
Wrapper objects can be used anywhere that objects are required instead of ____. | primitive data types
Which of the following is considered by the text to be the most important consideration when designing a class? | Each class should represent a single concept or object from the problem domain.
Which of the following questions should you ask yourself in order to determine if you have named your class properly? | Can I visualize an object of the class?
General Java variable naming conventions would suggest that a variable named NICKEL_VALUE would most probably be declared using which of the following combinations of modifiers? | public static final double
Which of the following is a good indicator that a class is overreaching and trying to accomplish too much? | The public interface refers to multiple concepts
Which of the following describes an immutable class? | A class that has accessor methods, but does not have mutator methods.
Mutator methods exhibit which of the following types of side effect? | Modification of the implicit parameter.
Why can't Java methods change parameters of primitive type? | Parameters of primitive type are considered by Java methods to be local variables.
Which of the following types of side effects potentially violates the rule of minimizing the coupling of classes? | Standard output.
Which of the following statements describes a precondition? | A requirement that the caller of a method must meet.
Which of the following statements describes an assertion? | A logical condition in a program that you believe to be true.
A static method can have which of the following types of parameters? | Only explicit parameters.
Why is a static variable also referred to as a class variable? | There is a single copy available to all objects of the class.
Which of the following statements generally describes the scope of a variable? | Which of the following statements generally describes the scope of a variable?
Under which of the following conditions can you have local variables with identical names? | If their scopes do not overlap.
Which of the following is not a reason to place classes into a package? | to make it easier to include a set of frequently used but unrelated classes
Which of the following statements about a Java interface is NOT true? | A Java interface must contain more than one method.
A method that has no implementation is called a/an ____ method. | abstract
Which of the following statements about abstract methods is true? | An abstract method has a name, parameters, and a return type, but no code in the body of the method.
____ are generated when the user presses a key, clicks a button, or selects a menu item. | Events.
Which of the following is an event source? | A JButton object.
Which of the following statements about an inner class is true? | The methods of an inner class can access variables declared in the enclosing scope.
How do you specify what the program should do when the user clicks a button? | Specify the actions to take in a class that implements the ActionListener interface.
When you use a timer, you need to define a class that implements the ____ | ActionListener
A class that represents the most general entity in an inheritance hierarchy is called a/an ____. | Superclass.
When designing a hierarchy of classes, features and behaviors that are common to all classes are placed in ____. | the superclass
To create a subclass, use the ____ keyword. | extends
Which of the following is true regarding subclasses? | A subclass inherits methods and instance variables from its superclass.
To override a superclass method in a subclass, the subclass method ____. | Must use the same method name and the same parameter types.
The ____reserved word is used to deactivate polymorphism and invoke a method of the superclass. | super
Which of the following is true regarding subclasses? | If a subclass does not call the superclass constructor, it must have a constructor without parameters.
Which of the following is true regarding inheritance? | A superclass can force a programmer to override a method in any subclass it creates.
Which of the following statements about a superclass is true? | An abstract method may be used in a superclass when there is no good default method for the superclass that will suit all subclasses' needs.
A class that cannot be instantiated is called a/an ____. | Abstract class.
The ____ reserved word in a method definition ensures that subclasses cannot override this | final
In Java, every class declared without an extends clause automatically extends which class? | Object
The java.util.Arrays class has a binarySearch(int[] arr, int key) method. Which statements are true regarding this method? (Choose all that apply.) | The method is static.,The return value is the index in the array of key.,The elements of the array must be sorted when the method is called.
The declaration of the java.util.Collection interface is interface Collection <E> The addAll() method of that interface takes a single argument, which is a reference to a collection whose elements are compatible with E. What is the declaration of the addAll() method? | public boolean addAll(Collection<? extends E> c)
Give the following declarations: Vector plainVec; Vector<String> fancyVec; If you want a vector in which you know you will only store strings, what are the advantages of using fancyVec rather than plainVec? | Attempting to add anything other than a string to fancyVec results in a compiler error.
When should objects stored in a Set implement the java.util.Comparable interface? | When the Set is a TreeSet
What relationship does the extends keyword represent? | "is a"
Suppose class aaa.Aaa has a method called callMe(). Suppose class bbb.Bbb, which extends aaa.AAA, wants to override callMe(). Which access modes for callMe() in aaa.AAA will allow this? | public,protected
Suppose you want to use a DateFormat to format an instance of Date. What factors influence the string returned by DateFormat's format() method? | The style, which is one of SHORT, MEDIUM, LONG, or FULL ,The locale
Suppose you want to create a class that compiles and can be serialized and deserialized without causing an exception to be thrown. Which statements are true regarding the class? (Choose all correct options.) | If the class implements java.io.Externalizable, it must have a no-args constructor.,If the class implements java.io.Serializable and does not implement java.io.Externalizable, its nearest superclass that doesn't implement Serializable must have a no-args constructor.
Suppose you are writing a class that will provide custom deserialization. The class implements java.io.Serializable (not java.io.Externalizable). What access mode should the readObject() method have? | private
What interfaces can be implemented in order to create a class that can be serialized? (Choose all that apply.) | Have the class declare that it implements java.io.Serializable. There are no methods in the interface.,Have the class declare that it implements java.io.Externalizable, which defines two methods: readExternal and writeExternal
Suppose you want to read a file that was not created by a Java program. The file contains lines of 8-bit text, and the 8-bit encoding represents the local character set, as represented by the cur- rent default locale. The lines are separated by newline characters. Which strategy reads the file and produces Java strings? | Create a FileReader instance. Pass it into the constructor of LineNumberReader. UseLineNumberReader's readLine() method.
Which of the following statements are true? (Choose all correct options.) | StringBuilder encapsulates a mutable string.,StringBuffer is threadsafe.
Suppose shorty is a short and wrapped is a Short. Which of the following are legal Java state- ments? (Choose all correct options.) | shorty = wrapped;,wrapped = shorty;,shorty = new Short((short)9);,shorty = 9;
How is IllegalArgumentException used? (Choose all correct options.) | It is thrown by certain methods of certain core Java classes to indicate that preconditions have been violated.,It should be used by programmers to indicate that preconditions of public methods have been violated.
While testing some code that you are developing, you notice that an ArrayIndexOutOf- BoundsException is thrown. What is the appropriate reaction? | None of the above.
Which are appropriate uses of assertions? | Checking preconditions in a private method,Checking postconditions in a private method,Checking postconditions in a public method
Which of the following types are legal arguments of a switch statement? | enums,bytes
Which of the following statements are true regarding the following method? void callMe(String... names) { } | Within the method, names is an array containing Strings.
Given a class with a public variable theTint of type Color, which of the following methods are consistent with the JavaBeans naming standards? | public Color getTheTint()
Which of the following are valid arguments to the DataInputStream constructor? | FileInputStream
Which of the following are valid mode strings for the RandomAccessFile constructor? (Choose all that apply.) | "r","rw", "rws","rwd"
Which of the following are true? (Choose all that apply.) | System.out has a println() method.
What method of the java.io.File class can create a file on the hard drive? | createNewFile()
Suppose class A extends Object; Class B extends A; and class C extends B. Of these, only class C implements java.io.Externalizable. Which of the following must be true in order to avoid an exception during deserialization of an instance of C? | C must have a no-args constructor.
Suppose class A extends Object; class B extends A; and class C extends B. Of these, only class C implements java.io.Serializable. Which of the following must be true in order to avoid an exception during deserialization of an instance of C? | B must have a no-args constructor.
Which of the following is true? | None of the above.
Which of the statements below are true? (Choose all that apply.) | None of the above.
Which of the following statements are true? | StringBuilder is generally faster than StringBuffer., StringBuffer is threadsafe; StringBuilder is not.
Which of the following are methods of the java.util.SortedMap interface? | headMap,tailMap,subMap
Which of the following classes implement java.util.List? | java.util.ArrayList, java.util.Stack
Which of the following are legal clone() methods in a class called Q13 that extends Object? | public Object clone() throws CloneNotSupportedException { return super.clone(); },public Q13 clone() throws CloneNotSupportedException { return (Q13)super.clone(); }
Map<String> names = new HashMap<String>(); which of the following are legal? (Choose all that apply.) | Iterator<String> iter = names.iterator();, for (String s:names)
Suppose prim is an int and wrapped is an Integer. Which of the following are legal Java statements? (Choose all that apply.) | prim = wrapped;,wrapped = prim;,prim = new Integer(9);,wrapped = 9;
Suppose you want to write a class that offers static methods to compute hyperbolic trigonometric functions. You decide to subclass java.lang.Math and provide the new functionality as a set of static methods. Which one statement is true about this strategy? | The strategy fails because you cannot subclass java.lang.Math.
Which of the following are true? (Choose all that apply.) | When you declare a method to be synchronized, the method always synchronizes on the lock of the current object.,When you declare a block of code inside a method to be synchronized, you can specify the object on whose lock the block should synchronize.
How can you ensure that multithreaded code does not deadlock? | A, B, and C do not ensure that multithreaded code does not deadlock.
Which of the following are true? | The JVM runs until there are no non-daemon threads.
Which of the following are true? (Choose all that apply.) | When an application begins running, there is one non-daemon thread, whose job is to execute main().,A thread created by a daemon thread is initially also a daemon thread.,A thread created by a non-daemon thread is initially also a non-daemon thread.
Is it possible to write code that can execute only if the current thread owns multiple locks? | Yes.
Which of the following calls may be made from a non-static synchronized method? | A call to the same method of the current object.,A call to the same method of a different instance of the current class.,A call to a different synchronized method of the current object.,A call to a static synchronized method of the current class.
Which of the following statements about the wait() and notify() methods is true? | The thread that calls wait() goes into the monitor's pool of waiting threads.
Which methods return an enum constant's name? | name(),toString()
Which of the following are true? | An anonymous inner class may implement at most one interface., An anonymous inner class may extend a parent class other than Object.
Given the following code, which of the following will compile? enum Spice { NUTMEG, CINNAMON, CORIANDER, ROSEMARY; } | Spice sp = Spice.NUTMEG; Object ob = sp;,Spice sp = Spice.NUTMEG; Object ob = (Object)sp;,Object ob = new Object(); Spice sp = (Spice)object;
Which of the following are true? (Choose all that apply.) | An enum definition may contain the main() ,You can call an enum's toString() method.,You can call an enum's wait() method.,You can call an enum's notify() method.
If all three top-level elements occur in a source file, they must appear in which order? | Package declaration, imports, class/interface/enum
Which of the following signatures are valid for the main() method entry point of an application?(Choose all that apply.) | public static void
Choose the valid identifiers from those listed here. (Choose all that apply.) | all
How do you change the value that is encapsulated by a wrapper class after you have instan- tiated it? | None of the above
Which of the following code snippets compile? | Integeri=7,Integeri=new,byteb=7
Select the list of primitives ordered in smallest to largest bit size representation. | None of the above
Select the valid primitive data types. (Select all that apply.) | boolean,char, float
The developer can force garbage collection by calling System.gc(). | False
The keyword extends refers to what type of relationship? | "is a"
Which access modifier allows you to access method calls in libraries not created in Java? | native
Select the order of access modifiers from least restrictive to most restrictive. | public, protected, default, private
You can determine all the keys in a Map in which of the following ways? | By getting a Set object from the Map and iterating through it.
Which of the following are valid declarations? Assume java.util.* is imported. | Vector, Set,Map
Inty but does not provide implementations for any of the five interface methods. Which is/are true? | The class will declared abstract,not be instantiated.
Suppose class Supe, in package packagea, has a method called doSomething(). Suppose class Subby, in package packageb, overrides doSomething(). What access modes may Subby's version of the method have? | public, protected
Which of the following may appear on the right-hand side of an instanceof operator? | A class,An interface
Which of the following are legal import statements? | import java.util.Vector,import static java.util.Vector.*
Suppose a source file contains a large number of import statements and one class definition.How do the imports affect the time required to load the class? | Class loading takes no additional time
Which of these is a process of writing the state of an object to a byte stream? | Serialization
Which of these process occur automatically by java run time system? | Serialization
Which of these is an interface for control over serialization and deserialization? | Externalization
Which of these interface extends DataOutput interface? | ObjectOutput
Which of these package contains classes and interfaces for networking? | java.net
Which of these is a protocol for breaking and sending packets to an address across a network? | TCIP/IP
How many ports of TCP/IP are reserved for specific protocols? | 1024
How many bits are in a single IP address? | 32
Which of these is a full form of DNS? | Domian Name Service
Which of these class is used to encapsulate IP address and DNS? | InetAddress
What does URL stands for? | Uniform Resource Locator
Which of these exception is thrown by URL class�s constructors? | MalformedURLException
Which of these methods is used to know host of an URL? | getHost()
Which of these methods is used to know the full URL of an URL object? | toExternalForm()
Which of these class is used to access actual bits or content information of a URL? | All of the mentioned
Which of these is wrapper around everything associated with a reply from an http server? | HTTP
Which of these tranfer protocol must be used so that URL can be accessed by URLConnection class object? | http
Which of these methods is used to know when was the URL last modified? | getLastModified()
Which of these methods is used to know the type of content used in the URL? | getContentType()
Which of these data member of HttpResponse class is used to store the response from a http server? | statusCode
Which of these interface abstractes the output of messages from httpd? | LogMessage
Which of these class is used to create servers that listen for either local or remote client programs? | ServerSockets
Which of these is a standard for communicating multimedia content over email? | Mime
Which of these methods is used to make raw MIME formatted string? | parse()
Which of these class is used for operating on request from the client to the server? | httpd
Which of these method of MimeHeader is used to return the string equivalent of the values stores on MimeHeader? | toString()
Which of these is an instance variable of class httpd? | All of the mentioned
Which of these is an instance variable of httpd that is a Hashtable? | log
Which of these methods of httpd class is used to read data from the stream? | getRawRequest()
Which of these method of httpd class is used to get report on each hit to HTTP server? | logEntry()
Which of these method is used to find a URL from the cache of httpd? | serveFromCache()
Which of these variables stores the number of hits that are successfully served out of cache? | hits.to.cache
Which of these method of httpd class is used to write UrlCacheEntry object into local disk? | writeDiskCache()
Which of these method is used to start a server thread? | run()
Which of these method is called when http daemon is acting like a normal web server? | handleGet()
Which of these is a bundle of information passed between machines? | Datagrams
Which of these class is necessary to implement datagrams? | All of the mentioned
Which of these method of DatagramPacket is used to find the port number? | port()
Which of these method of DatagramPacket is used to obtain the byte array of data contained in a datagram? | getData()
Which of these method of DatagramPacket is used to find the length of byte array? | getLength()
Which of these class must be used to send a datatgram packets over a connection? | All of the mentioned
Which of these method of DatagramPacket class is used to find the destination address? | getAddress()
Which of these is a return type of getAddress method of DatagramPacket class? | InetAddress
1. Which of these method is used to implement Runnable interface? | run()
Which of these interface is implemented by Thread class? | Runnable
Which of these method waits for the thread to treminate? | join()
Which of these statement is incorrect? | run() method is used to begin execution of a thread before start() method in special
Which of these method can be used to make the main thread to be executed last among all the threads? | sleep()
Which of these method is used to find out that a thread is still running or not? | isAlive()
What is the default value of priority variable MIN_PRIORITY AND MAX_PRIORITY? | 1 & 10
Which of these method is used to explicitly set the priority of a thread? | setPriority()
What is synchronization in reference to a thread? | It's a process of handling situations when two or more threads need access to a shared resource.
. What is the default value of priority variable MIN_PRIORITY AND MAX_PRIORITY? | 1 & 10
. Which of these method waits for the thread to treminate? | join()
Which of these statement is incorrect? | run() method is used to begin execution of a thread before start() method in special cases.
. Which of these class is used to make a thread? | Runnable
Which of these method of Thread class is used to find out the priority given to a thread? | getPriority()
. Which of these method of Thread class is used to Suspend a thread for a period of time? | sleep()
. Which function of pre defined class Thread is used to check weather current thread being checked is still running? | isAlive()
17. What is multithreaded programming? | It's a process in which two or more parts of same process run simultaneously.
Which of these packages contain all the Java's built in exceptions? | java.lang
What will happen if two thread of same priority are called to be processed simultaneously? | It is dependent on the operating system.
Which of the following layout managers honours the preferred size of a component: | GridLayout
You should always invoke the unlock method in the finally clause. | true
3 Which of the following expressions must be true if you create a thread using Thread = new Thread(object)? | object instanceof Runnable
How do you create a condition on a lock? | Condition condition = lock.newCondition();
To run an object on a separate thread, the object must be a subclass of Thread. | true
The Runnable interface is more general than the Thread class. You can convert any class that extends Thread to a class that implements Runnable. | true
8 An exception occurs if the resume() method is invoked by a finished thread object. | true
You can set a priority for an object of ThreadGroup using the setPrority() method. | false
You must specify a name for the thread group that you will create. | true
You should not directly invoke the run() method of a thread object. | true
When creating a server on a port that is already in use, __________. | java.net.BindException occurs.
To obtain an ObjectInputStream from a socket, use ________. | socket.getObjectStream()
You can invoke ______________ on a Socket object, say socket, to obtain an InetAddress object.ocket.getInetAddress(); | socket.getInetAddress();
To connect to a server running on the same machine with the client, which of the following can be used for the hostname? | All of the above.
The server listens for a connection request from a client using the following statement: | Socket s = serverSocket.accept()
The server can create a server socket regardless of whether the port is in use or not. | false
The client can connect to the server regardless of whether the port is in use or not. | true
You cannot get instances of InputStream or OutputStream because InputStream and OutputStream are abstract classes. | false
An applet cannot connect to a server program on a Web server where the applet was loaded. | true
You can transmit objects over the socket. | true
The URL constructor throws MalformedURLException if the URL is syntactically incorrect. | false
getInputStream() and getOutputStream() are used to produce InputStream and OutputStream on the socket. | true
Which of the following statements are true? | NumberFormat using the static ..DecimalFormat..An instance created
Which of the following are in the java.text package? | DateFormat.SimpleDateFormat .DateFormatSymbols
Which of the following code is correct to obtain hour from a Calendar object cal? | cal.get(Calendar.HOUR);
How do you create a locale for the United States? | new Locale("en", "US"); ..Locale.US;
A resource bundle is ___________ | a Java class file or a text file that provides locale-specific information.
To display number in desired format, you have to use the NumberFormat class or its subclasses. | true
You can find all the available locales from a Swing object. | false
The locale property is in the Component class, thus, every Java Swing component has the locale property. | true
You can get year, month, day, hour, minute, and second from an instance of GregorianCalendar. | true
The TimeZone class has a static method for obtaining all the available time zone IDs. | true
You can get all the available locales from an instance of Calendar, Collator, DateFormat, or NumberFormat. | true
The data in DefaultTableModel are stored in ___________. | a Vector
DefaultTableModel contains the methods for | adding a column ..inserting a new row..adding a new row
DefaultTableModel contains the methods for | inserting a new row..adding a column..adding a new row
Invoking Class.forName method may throw ___________. | ClassNotFoundException
Which of the following are interfaces? | Statement ..ResultSet.. Connection
In a relational data model, _________ defines the representation of the data. | Structure
Which of the following statements loads the JDBC-ODBC driver? | Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
To create a statement on a Connection object conn, use | Statement statement = conn.createStatement();
SQL ________ statements may change the contents of a database. | INSERT UPDATE DELETE
22 A database URL for an access database source test is ________. | jdbc:odbc:test
Database meta data are retrieved through ____________. | a Connection object
What is the return value from stmt.executeUpdate("insert into T values (100, 'Smith')") | an int value indicating how many rows are effected from the invocation
25 ________ are known as intra-relational constraints, meaning that a constraint involves only one relation. | Domain constraints..Primary key constraints
A database URL for a MySQL database named test on host panda.armstrong.edu is ________. | jdbc:mysql://panda.armstrong.edu/test
27 In a relational data model, _________ imposes constraints on the data. | Integrity
To execute a SELECT statement "select * from Address" on a Statement object stmt, use | stmt.executeQuery("select * from Address");
29 _________ specify the permissible values for an attribute. | Domain constraints
Suppose that your program accesses MySQL or Oracle database. Which of the following statements are true? | x2the program will have a runtime error
31 What information may be obtained from a ResultSetMetaData object? | number of columns in the result set
32 ________ is an attribute or a set of attributes that uniquely identifies the relation. | A superkey
Which of the following statements are true? | -cau "for SQL query"
34 Where is com.mysql.jdbc.Driver located? | in a JAR file mysqljdbc.jar
In a relational data model, ________ provides the means for accessing and manipulating data. | Language SQL
To connect to a local MySQL database named test, use | Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/test");
Result set meta data are retrieved through ____________. | a ResultSet Object
You want to construct a text area that is 80 character-widths wide and 10 character-heights tall. What code do you use? | new TextArea(10, 80)
A text field has a variable-width font. It is constructed by calling new TextField("iiiii"). What happens if you change the contents of the text field to "wwwww"? (Bear in mind that i is one of the narrowest characters, and w is one of the widest.) | The text field stays the same width; to see the entire contents you will have to scroll by using the � and � keys.
The CheckboxGroup class is a subclass of the Component class. | False
What are the immediate super classes of the following classes? | Container class
Which Component method is used to access a component's immediate Container? | getParent()
17) Which of the following are direct or indirect subclasses of Component? | Button Label Frame
Which of the following are direct or indirect subclasses of Container? | Frame FileDialog Applet
Which method is used to set the text of a Label object? | setText( )
Which constructor creates a TextArea with 10 rows and 20 columns? | new TextArea(10, 20)
Which of the following creates a List with 5 visible items and multiple selection enabled? | new List(5, true)
Which are true about the Container class? | -cau The getBorder( )
Suppose a Panel is added to a Frame and a Button is added to the Panel. If the Frame's font is set to 12-point TimesRoman, the Panel's font is set to 10-point TimesRoman, and the Button's font is not set, what font will be used to display the Button's label? | 10-point TimesRoman
A Frame's background color is set to Color. Yellow, and a Button's background color is to Color.Blue. Suppose the Button is added to a Panel, which is added to the Frame. What background color will be used with the Panel? | Colr.Yellow
Which method will cause a Frame to be displayed? | show( ) setVisible( )
Which of the following components allow multiple selections? | Non-exclusive Checkboxes. List.
Which method is method to set the layout of a container? | setLayout( )
Which method returns the preferred size of a component? | getPreferredSize( )
Which layout should you use to organize the components of a container in a tabular form? | GridLayout
An application has a frame that uses a Border layout manager. Why is it probably not a good idea to put a vertical scroll bar at North in the frame? | Both a and b.
If a frame uses a Grid layout manager and does not contain any panels, then all the components within the frame are the same width and height. | True
If a frame uses its default layout manager and does not contain any panels, then all the components within the frame are the same width and height. | False.
With a Border layout manager, the component at Center gets all the space that is left over, after the components at North and South have been considered. | False
An Applet has its Layout Manager set to the default of FlowLayout. What code would be the correct to change to another Layout Manager? | setLayout(new GridLayout(2,2));
How do you indicate where a component will be positioned using Flowlayout? | Do nothing, the FlowLayout will position the component
How do you change the current layout manager for a container? | Use the setLayout method
When using the GridBagLayout manager, each new component requires a new instance of the GridBagConstraints class. Is this statement true or false? | false
What happens if you change the contents of the text field to "wwwww"? | The text field stays the same ... using the � and �Ekeys.
What is meant by Controls and what are different types of controls? | Labels,Push buttons,Check boxes,Choice lists,Lists,Scroll bars,Text components
What Checkbox method allows you to tell if a Checkbox is checked? | getState()
What methods are used to get and set the text label displayed by a Button object? | getLabel() and setLabel()
What is the difference between a Choice and a List? | Choice is displayed in a compact form that requires..choices
Which Container method is used to cause a container to be laid out and redisplayed? | validate()
What is the difference between a Scollbar and a Scrollpane? | A Scrollbar is a Component,but not a Container.
Which Component subclass is used for drawing and painting? | Canvas.
Which of the following are direct or indirect subclasses of Component? | Button,Label,Frame!Frame
Which method is used to set the text of a Label object? | setText()
Which constructor creates a TextArea with 10 rows and 20 columns? | Usage is TextArea(rows, columns)
Which are true about the Container class? | The validate( )..,The add( ) ..,The getComponent( )..
what font will be used to display the Button label? | 10-point TimesRoman
What background color will be used with the Panel? | Colr.Yellow
Which method will cause a Frame to be displayed? | show(),setVisible()