forked from IncludeKyle/JavaQuizFinal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestionBank.txt
439 lines (439 loc) · 10.9 KB
/
questionBank.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
? What is a character literal representing the upper case letter A?
C14
S2
(A) 65
(B) 'A'<
(C) A
(D) 'a'
$
? Assume C is a char; the expression (C != ' ') will?
C14
S2
(A) Will evaluate to true if equal to a space
(B) Will evaluate to false if equal to a space<
(C) Will fail to evaluate because C needs to be a string
$
? If char x = 'A', Character.isUpperCase(x) will return?
C14
S2
(T) True<
(F) False
$
? String word = 'Name'; will assign the string to this variable?
C14
S3
(A) False, because word is not an integer
(B) True
(C) False, because 'Name' is not a string<
$
? If String aWord contains "hello", aWord.length() will return?
C14
S3
(A) "five"
(B) "hello"
(C) 5<
(D) 4
$
? String word = "hello"; What does word.charAt(0) return?
C14
S3
(A) True
(B) 5
(C) "h"<
(D) "hello"
$
? The statement: name.charAt(name.length()-1) will always return what?
C14
S3
(A) The last char of the string name<
(B) An int of the length of string name
(C) The string contents of string name
(D) True
$
? String word = "yeet"; (word.charAt(0) == 'y') will evaluate to?
C14
S3
(T) True<
(F) False
$
? Write the declaration of a String method that takes two String parameters:
C14
S3
(A) public String processInput(int number) { //... }
(B) public void processInput(String a, String b) { //... }
(C) public String processInput(String word1, String word2) { //... }<
(D) public int processInput(String word1, String word2) { //... }
$
? String word = "Litty"; word.substring(0,3) returns?
C14
S3
(A) "Litty"
(B) 't'
(C) 5
(D) "Lit"<
$
?An array is a group of variables (called elements or components) containing values that all have the same type?
C7
S2
(A) t<
(B) f
$
?Arrays are created with keyword?
C7
S3
(A) new<
(B) make
(C) name
(D) call
$
?The first element in every array has index?
C7
S2
(A) 0<
(B) 1
(C) -1
(D) 2
$
?A GOOD example of declaring an array variable would be?
C7
S3
(A) int[]c;<
(B) int c;
(C) int()c;
(D) int[c];
$
?You can create an array and initialize its elements with an array initializer?
C7
S4.2
(A) t<
(B) f
$
?To pass an array argument to a method, specify the name of the array without any brackets?
C7
S8
(A) t<
(B) f
$
?The collection class ArrayList<E> can dynamically change its size to accommodate more elements?
C7
S16
(A) t<
(B) f
$
?What static method can be used to compare arrays?
C7
S15
(A) sort()
(B) equals()<
(C) fill()
(D) binarySearch()
$
?Arrays that require two indices to identify each element are called?
C7
S11
(A) two-dimensional arrays<
(B) three-dimensional arrays
(C) one-dimensional arrays
(D) none of the above
$
?Unlike some other languages, Java does not allow you to choose pass-by-value or pass-by-reference-all arguments are passed by value?
C7
S9
(A) t<
(B) f
$
? Superclass constructors are not inherited by subclasses. ?
C9
S2
(A) t<
(B) f
$
? Methods of a subclass cannot directly access private members of their superclass. ?
C9
S3
(A) t<
(B) f
$
? A subclass can change the state of private superclass instance variables only through: ?
C9
S3
(A) A subclass cannot change the state of private superclass instance variables.
(B) Non-Private methods provided in the super class and inherited by that subclass.<
$
? Declaring private instance variables helps you test, debug and correctly modify system. ?
C9
S3
(A) t<
(B) f
$
? Why does declare overridden method with annotation ‘@Override’ is a good idea ?
C9
S4
(A) It doesn’t have any useful function to the current program.
(B) To ensure at compilation time that you defined their signatures correctly.
(C) It is always better to find errors at compile time rather than at runtime.
(D) A and B.<
$
? Why inheritance is useful in terms of software engineering ?
C9
S4
(A) It reduces the use of memory.
(B) It makes the program run faster.
(C) It is more convenience when a developer wants to make changes in their source code. <
$
? Does declaring a subclass affect its superclass’s source code ?
C9
S4
(A) Yes. It will erase all the instance variables in its superclass.
(B) No. Inheritance preserves the integrity of the super class.<
$
? What a subclass can contain from its superclass ?
C9
S4
(A) It doesn’t contain anything from its superclass.
(B) It contains all instance variables from its super class.
(C) It contains all instance variables and all methods from its superclass.<
$
? How can a subclass access to its superclass’s instance variables ?
C9
S4
(A) Since it inherits its superclass, it can access to its superclass’s instance variables whenever it wants.
(B) The instance variables have to be declared with the private keyword.
(C) The instance variables have to be declared with protected keyword.<
$
? All classes in java inherit directly or indirectly from class Object. So how many methods that Object class has ?
C9
S6
(A) 9
(B) 10
(C) 11<
(D) 12
$
? What is recursion?
C18
S1
(A) A subclass calling a superclass
(B) Data structures consisting of related data items of the same type
(C) A method that calls on itself either directly or indirectly<
(D) An incomplete class that doesn’t create any objects
$
? What is indirect recursion?
C18
S2
(A) When a method calls upon itself
(B) When a method calls another method which then calls on the original method<
(C) When a method calls an abstract class
$
? What would happen if the base case were omitted from the recursion ?
C18
S4
(A) Compiler Error
(B) Infinite Loop
(C) Infinite Recursion<
(D) Nothing
$
? What do iteration and recursion NOT have in common?
C18
S7
(A) They each need a termination test
(B) They both gradually approach termination
(C) They both use a selection statement<
(D) They both involve iteration
$
? Any problem that can be solved recursively can be solved iteratively and vice versa?
C18
S7
(A) True<
(B) False
$
? What is recursive back tracking?
C18
S10
(A) Using recursion to return to an earlier decision point<
(B) A syntax error
(C) A compiler error
(D) A method of debugging
$
? What is a drawback to recursion?
C18
S5
(A) It can only solve simple problems
(B) It is difficult to debug
(C) The more times it calls itself, the longer it takes to compute<
(D) The solution is not always apparent
$
? Why are fractals used when teaching recursion?
C18
S9
(A) They require a lot of math equations
(B) They are easy to debug
(C) They create a form by repeating a pattern<
(D) They are a good introduction to GUIs
$
? A ____ is needed to terminate recursion?
C18
S1
(A) recursion step
(B) void return type
(C) break statement
(D) base case<
$
? Each time a fractal’s pattern is applied, the fractal is said to be at a new _____?
C18
S9
(A) width
(B) height
(C) level<
(D) volume
$
? Which type of data is permanently stored?
C15
S1
(A) Arrays
(B) String
(C) Int
(D) Files<
$
? What is “Path”?
C15
S3
(A) It represents the location of the file<
(B) It opens the file
(C) It is used when altering the file
(D) It creates a new file
$
? Which class is used for file output?
C15
S3
(A) Scanner
(B) Formatter<
(C) Files
(D) Paths
$
? Which class is used for file input?
C15
S3
(A) Scanner<
(B) Formatter
(C) Files
(D) Path
$
? A file must be closed and reopened when wanting to read data in the file multiple times?
C18
S3
(A) True<
(B) False
$
? Write a single statement that declares a reference variable of type Integer named myInt, creates an object of type Integer with the initial value of 75, and assigns it to the reference variable.
C16
S16
(A) Integer myInt = new Integer(75); <
(B) Integer myInt;
(C) Integer myInt = new Integer(seventyFive);
$
? Suppose a reference variable of type Double called myDouble has already been declared. There is also a double variable x that has been declared and initialized. Create an object of type Double with the initial value of x and assign it to the reference variable myDouble.
C16
S16
(A) myString2 = new String(x);
(B) Double myDouble2 = new Double(x);
(C) myDouble = myDouble2; <
(D) myFloat2 = new Float(x);
$
? Suppose a reference variable of type Integer called myInt is already declared. Create an object of type Integer with the initial value of 1 and assign it to the reference variable myInt.
C16
S16
(A) myInt = new Integer(1); <
(B) myInt = new Int();
(C) none of the above
$
? Suppose a reference variable of type Long called myLong is already declared. Create an object of type Long with the initial value of two billion and assign it to the reference variable myLong.
C16
S16
(A) myLong = myLong();
(B) myLong = new Float();
(C) myLong = new Long(2000000000L); <
$
? Suppose a reference variable of type Double called myDouble is already declared. Create an object of type Double with the initial value of 1.5 and assign it to the reference variable myDouble.
C16
S16
(A) myDouble = new Double(1.5);<
(B) myLong = new Float();
(C) none of the above
$
? Suppose a reference variable of type Double called myDouble has already been declared . There is also a double variable x that has been declared and initialized . Create an object of type Double with the initial value of x and assign it to the reference variable myDouble.
C16
S16
(A) myDouble = new Double(x);<
(B) myString = new String(x);
(C) none of the above
$
? Given an ArrayList a, write an expression that refers to the first element of the ArrayList.
C16
S16
(A) a.get();
(B) a.get(0); <
(C) a.get(first);
$
? Which of these is a reason to use a lambda?
C17
S0
(A) To serve as a pointer to a memory address
(B) Changing the value of a final type variable
(C) Functional programming; to pass methods as data with a functional interface <
$
? A lambda expression should have an argument list, arrow token, and a body: (int x, int y) -> x+y
C17
S0
(T) True <
(F) False
$
? Lambdas don't allow you to pipe multiple methods together:
C17
S0
(A) True, you can't pipe multiple methods
(B) False, they do allow piping multiple methods <
(C) False, lambdas require that multiple methods be piped together
$
? Lambdas allow for streams with less code?
C17
S0
(T) True <
(F) False
$
? Lambdas remove the need for what?
C17
S0
(A) Comments that clarify and explain code
(B) Anonymous inner classes <
(C) Semicolons at the end of code statements
$
? Concurrency is the ability to run several programs or several parts of a program in parallel
C23
S0
(T) <
(F)
$
? A thread is a lightweight process which has its own call stack, but can access shared data of other threads in the same process
C23
S0
(T) <
(F)
$
? Concurrency is another name for Parallelism.
C23
S0
(T)
(F) <
$
? sleep() is not method and its not used to pause a process for few seconds or a period time we want to.
C23
S0
(T)
(F) <
$
? Modern computers has several CPU’s or several cores within one CPU, enabling programs to utilize all cores for some part of processing.
C23
S0
(T) <
(F)
$