-
Notifications
You must be signed in to change notification settings - Fork 0
/
Java Interview Questions.json
775 lines (775 loc) · 53.2 KB
/
Java Interview Questions.json
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
{
"id": "a8a9593f-440a-4732-a087-5f6219a381dc",
"name": "Java Interview Questions",
"auto": true,
"contexts": [],
"responses": [
{
"resetContexts": false,
"affectedContexts": [],
"parameters": [],
"messages": [
{
"type": "simple_response",
"platform": "google",
"items": [
{
"textToSpeech": "Q: What do you know about Java?\nA: Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX."
},
{
"textToSpeech": "Q: What are the supported platforms by Java Programming Language?\n A: Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX/Linux like HP-Unix, Sun Solaris, Redhat Linux, Ubuntu, CentOS, etc."
},
{
"textToSpeech": "Q: How Java enabled High Performance?\n A: Java uses Just-In-Time compiler to enable high performance. Just-In-Time compiler is a program that turns Java bytecode, which is a program that contains instructions that must be interpreted into instructions that can be sent directly to the processor."
},
{
"textToSpeech": "Q: Why Java is considered dynamic?\n A: It is designed to adapt to an evolving environment. Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time."
},
{
"textToSpeech": "Q: What is Java Virtual Machine and how it is considered in context of Java’s platform independent feature?\n A: When Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the web and interpreted by virtual Machine (JVM) on whichever platform it is being run."
},
{
"textToSpeech": "Q: List two Java IDE’s?\n A: Netbeans, Eclipse, etc."
},
{
"textToSpeech": "Q: List some Java keywords(unlike C, C++ keywords)?\n A: Some Java keywords are import, super, finally, etc."
},
{
"textToSpeech": "Q: What do you mean by Object?\n A: Object is a runtime entity and it’s state is stored in fields and behavior is shown via methods.Methods operate on an object's internal state and serve as the primary mechanism for object-to-object communication."
},
{
"textToSpeech": "Q: Define class?\n A: A class is a blue print from which individual objects are created. A class can contain fields and methods to describe the behavior of an object."
},
{
"textToSpeech": "Q: What kind of variables a class can consist of?\n A: A class consist of Local variable, instance variables and class variables."
},
{
"textToSpeech": "Q: What is a Local Variable\n A: Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and it will be destroyed when the method has completed."
},
{
"textToSpeech": "Q: What is a Instance Variablen A: Instance variables are variables within a class but outside any method. These variables are instantiated when the class is loaded."
},
{
"textToSpeech": "Q: What is a Class Variable\n A: These are variables declared with in a class, outside any method, with the static keyword."
},
{
"textToSpeech": "Q: What is Singleton class?\n A: Singleton class control object creation, limiting the number to one but allowing the flexibility to create more objects if the situation changes."
},
{
"textToSpeech": "Q: What do you mean by Constructor?\n A: Constructor gets invoked when a new object is created. Every class has a constructor. If we do not explicitly write a constructor for a class the java compiler builds a default constructor for that class."
},
{
"textToSpeech": "Q: List the three steps for creating an Object for a class?\n A: An Object is first declared, then instantiated and then it is initialized."
},
{
"textToSpeech": "Q: What is the default value of byte datatype in Java?\n A: Default value of byte datatype is 0."
},
{
"textToSpeech": "Q: What is the default value of float and double datatype in Java?\n A: Default value of float and double datatype in different as compared to C/C++. For float its 0.0f and for double it’s 0.0d."
},
{
"textToSpeech": "Q: When a byte datatype is used?\n A: This data type is used to save space in large arrays, mainly in place of integers, since a byte is four times smaller than an int."
},
{
"textToSpeech": "Q: What is a static variable?\n A: Class variables also known as static variables are declared with the static keyword in a class, but outside a method, constructor or a block."
},
{
"textToSpeech": "Q: What do you mean by Access Modifier?\n A: Java provides access modifiers to set access levels for classes, variables, methods and constructors. A member has package or default accessibility when no accessibility modifier is specified."
},
{
"textToSpeech": "Q: What is protected access modifier?\n A: Variables, methods and constructors which are declared protected in a superclass can be accessed only by the subclasses in other package or any class within the package of the protected members' class."
},
{
"textToSpeech": "Q: What do you mean by synchronized Non Access Modifier?\n A: Java provides these modifiers for providing functionalities other than Access Modifiers, synchronized used to indicate that a method can be accessed by only one thread at a time."
},
{
"textToSpeech": "Q: According to Java Operator precedence, which operator is considered to be with highest precedence?\n A: Postfix operators i.e () [] . is at the highest precedence."
},
{
"textToSpeech": "Q: Variables used in a switch statement can be used with which datatypes?\n A: Variables used in a switch statement can only be a byte, short, int, or char."
},
{
"textToSpeech": "Q: When parseInt() method can be used?\n A: This method is used to get the primitive data type of a certain String."
},
{
"textToSpeech": "Q: Why is String class considered immutable?\n A: The String class is immutable, so that once it is created a String object cannot be changed. Since String is immutable it can safely be shared between many threads ,which is considered very important for multithreaded programming."
},
{
"textToSpeech": "Q: Why is StringBuffer called mutable?\n A: The String class is considered as immutable, so that once it is created a String object cannot be changed. If there is a necessity to make alot of modifications to Strings of characters then StringBuffer should be used."
},
{
"textToSpeech": "Q: What is the difference between StringBuffer and StringBuilder class?\n A: Use StringBuilder whenever possible because it is faster than StringBuffer. But, if thread safety is necessary then use StringBuffer objects."
},
{
"textToSpeech": "Q: Which package is used for pattern matching with regular expressions?\n A: java.util.regex package is used for this purpose."
},
{
"textToSpeech": "Q: java.util.regex consists of which classes?\n A: java.util.regex consists of three classes: Pattern class, Matcher class and PatternSyntaxException class."
},
{
"textToSpeech": "Q: What is finalize() method?\n A: It is possible to define a method that will be called just before an object's final destruction by the garbage collector. This method is called finalize( ), and it can be used to ensure that an object terminates cleanly."
},
{
"textToSpeech": "Q: What is an Exception?\n A: An exception is a problem that arises during the execution of a program. Exceptions are caught by handlers positioned along the thread's method invocation stack."
},
{
"textToSpeech": "Q: What do you mean by Checked Exceptions?\n A: It is an exception that is typically a user error or a problem that cannot be foreseen by the programmer. For example, if a file is to be opened, but the file cannot be found, an exception occurs. These exceptions cannot simply be ignored at the time of compilation."
},
{
"textToSpeech": "Q: Explain Runtime Exceptions?\n A: It is an exception that occurs that probably could have been avoided by the programmer. As opposed to checked exceptions, runtime exceptions are ignored at the time of compliation."
},
{
"textToSpeech": "Q: Which are the two subclasses under Exception class?\n A: The Exception class has two main subclasses : IOException class and RuntimeException Class."
},
{
"textToSpeech": "Q: When throws keyword is used?\n A: If a method does not handle a checked exception, the method must declare it using the throwskeyword. The throws keyword appears at the end of a method's signature."
},
{
"textToSpeech": "Q: When throw keyword is used?\n A: An exception can be thrown, either a newly instantiated one or an exception that you just caught, by using throw keyword."
},
{
"textToSpeech": "Q: How finally used under Exception Handling?\n A: The finally keyword is used to create a block of code that follows a try block. A finally block of code always executes, whether or not an exception has occurred."
},
{
"textToSpeech": "Q: What things should be kept in mind while creating your own exceptions in Java?\n A: While creating your own exception:\n• All exceptions must be a child of Throwable.• If you want to write a checked exception that is automatically enforced by the Handle or Declare Rule, you need to extend the Exception class.• You want to write a runtime exception, you need to extend the RuntimeException class."
},
{
"textToSpeech": "Q: Define Inheritance?\n A: It is the process where one object acquires the properties of another. With the use of inheritance the information is made manageable in a hierarchical order."
},
{
"textToSpeech": "Q: When super keyword is used?\n A: If the method overrides one of its superclass's methods, overridden method can be invoked through the use of the keyword super. It can be also used to refer to a hidden field"
},
{
"textToSpeech": "Q: What is Polymorphism?\n A: Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object."
},
{
"textToSpeech": "Q: What is Abstraction?\n A: It refers to the ability to make a class abstract in OOP. It helps to reduce the complexity and also improves the maintainability of the system."
},
{
"textToSpeech": "Q: What is Abstract class\n A: These classes cannot be instantiated and are either partially implemented or not at all implemented. This class contains one or more abstract methods which are simply method declarations without a body."
},
{
"textToSpeech": "Q: When Abstract methods are used?\n A: If you want a class to contain a particular method but you want the actual implementation of that method to be determined by child classes, you can declare the method in the parent class as abstract."
},
{
"textToSpeech": "Q: What is Encapsulation?\n A: It is the technique of making the fields in a class private and providing access to the fields via public methods. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. Therefore encapsulation is also referred to as data hiding."
},
{
"textToSpeech": "Q: What is the primary benefit of Encapsulation?\n A: The main benefit of encapsulation is the ability to modify our implemented code without breaking the code of others who use our code. With this Encapsulation gives maintainability, flexibility and extensibility to our code."
},
{
"textToSpeech": "Q: What is an Interface?\n A: An interface is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface."
},
{
"textToSpeech": "Q: Give some features of Interface?\n A: It includes:• Interface cannot be instantiated• An interface does not contain any constructors. All of the methods in an interface are abstract."
},
{
"textToSpeech": "Q: Define Packages in Java?\n A: A Package can be defined as a grouping of related types(classes, interfaces, enumerations and annotations ) providing access protection and name space management."
},
{
"textToSpeech": "Q: Why Packages are used?\n A: Packages are used in Java in-order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations, etc., easier."
},
{
"textToSpeech": "Q: What do you mean by Multithreaded program?\n A: A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called a thread, and each thread defines a separate path of execution."
},
{
"textToSpeech": "Q: What are the two ways in which Thread can be created?\n A: Thread can be created by: implementing Runnable interface, extending the Thread class."
},
{
"textToSpeech": "Q: What is an applet?\n A: An applet is a Java program that runs in a Web browser. An applet can be a fully functional Java application because it has the entire Java API at its disposal."
},
{
"textToSpeech": "Q: An applet extend which class?\n A: An applet extends java.applet.Applet class."
},
{
"textToSpeech": "Q: Explain garbage collection in Java?\n A: It uses garbage collection to free the memory. By cleaning those objects that is no longer reference by any of the program."
},
{
"textToSpeech": "Q: Define immutable object?\n A: An immutable object can’t be changed once it is created."
},
{
"textToSpeech": "Q: Explain the usage of this() with constructors?\n A: It is used with variables or methods and used to call constructer of same class."
},
{
"textToSpeech": "Q: Explain Set Interface?\n A: It is a collection of element which cannot contain duplicate elements. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited."
},
{
"textToSpeech": "Q: Explain TreeSet?\n A: It is a Set implemented when we want elements in a sorted order."
},
{
"textToSpeech": "Q: What is Comparable Interface?\n A: It is used to sort collections and arrays of objects using the collections.\n sort() and java.\n utils.\n The objects of the class implementing the Comparable interface can be ordered."
},
{
"textToSpeech": "Q: Difference between throw and throws?\n A: It includes:\n • Throw is used to trigger an exception where as throws is used in declaration of exception.\n • Without throws, Checked exception cannot be handled where as checked exception can be propagated with throws."
},
{
"textToSpeech": "Q: Explain the following line used under Java Program:public static void main (String args[ ])\n A: The following shows the explanation individually:• public: it is the access specifier.• static: it allows main() to be called without instantiating a particular instance of a class.• void: it affirns the compiler that no value is returned by main().\n • main(): this method is called at the beginning of a Java program.\n • String args[ ]: args parameter is an instance array of class String"
},
{
"textToSpeech": "Q: Define JRE i. Java Runtime Environment?\n A: Java Runtime Environment is an implementation of the Java Virtual Machine which executes Java programs. It provides the minimum requirements for executing a Java application;"
},
{
"textToSpeech": "Q: What is JAR file?\n A: JAR files is Java Archive fles and it aggregates many files into one. It holds Java classes in a library. JAR files are built on ZIP file format and have .jar file extension."
},
{
"textToSpeech": "Q: What is a WAR file?\n A: This is Web Archive File and used to store XML, java classes, and JavaServer pages. which is used to distribute a collection of JavaServer Pages, Java Servlets, Java classes, XML files, static Web pages etc."
},
{
"textToSpeech": "Q: Define JIT compiler?\n A: It improves the runtime performance of computer programs based on bytecode."
},
{
"textToSpeech": "Q: What is the difference between object oriented programming language and object based programming language?\n A: Object based programming languages follow all the features of OOPs except Inheritance. JavaScript is an example of object based programming languages"
},
{
"textToSpeech": "Q: What is the purpose of default constructor?\n A: The java compiler creates a default constructor only if there is no constructor in the class."
},
{
"textToSpeech": "Q: Can a constructor be made final?\n A: No, this is not possible."
},
{
"textToSpeech": "Q: What is static block?\n A: It is used to initialize the static data member, It is excuted before main method at the time of classloading."
},
{
"textToSpeech": "Q: Define composition?\n A: Holding the reference of the other class within some other class is known as composition."
},
{
"textToSpeech": "Q: What is function overloading?\n A: If a class has multiple functions by same name but different parameters, it is known as Method Overloading."
},
{
"textToSpeech": "Q: What is function overriding?\n A: If a subclass provides a specific implementation of a method that is already provided by its parent class, it is known as Method Overriding."
},
{
"textToSpeech": "Q: Difference between Overloading and Overriding?\n A: Method overloading increases the readability of the program. Method overriding provides the specific implementation of the method that is already provided by its super class parameter must be different in case of overloading, parameter must be same in case of overriding."
},
{
"textToSpeech": "Q: What is final class?\n A: Final classes are created so the methods implemented by that class cannot be overridden. It can’t be inherited.Q: What is NullPointerException?\n A: A NullPointerException is thrown when calling the instance method of a null object, accessing or modifying the field of a null object etc."
},
{
"textToSpeech": "Q: What are the ways in which a thread can enter the waiting state?\n A: A thread can enter the waiting state by invoking its sleep() method, by blocking on IO, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method."
},
{
"textToSpeech": "Q: How does multi-threading take place on a computer with a single CPU?\n A: The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially."
},
{
"textToSpeech": "Q: What invokes a thread's run() method?\n A: After a thread is started, via its start() method of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed."
},
{
"textToSpeech": "Q: Does it matter in what order catch statements for FileNotFoundException and IOException are written?\n A: Yes, it does. The FileNoFoundException is inherited from the IOException. Exception's subclasses have to be caught first."
},
{
"textToSpeech": "Q: What is the difference between yielding and sleeping?\n A: 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."
},
{
"textToSpeech": "Q: Why Vector class is used?\n A: The Vector class provides the capability to implement a growable array of objects. Vector proves to be very useful if you don't know the size of the array in advance, or you just need one that can change sizes over the lifetime of a program."
},
{
"textToSpeech": "Q: How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?\n A: Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns."
},
{
"textToSpeech": "Q: What are Wrapper classes?\n A: These are classes that allow primitive types to be accessed as objects. Example: Integer, Character, Double, Boolean etc."
},
{
"textToSpeech": "Q: What is the difference between a Window and a Frame?\n A: The Frame class extends Window to define a main application window that can have a menu bar."
},
{
"textToSpeech": "Q: Which package has light weight components?\n A: javax.Swing package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are lightweight components."
},
{
"textToSpeech": "Q: What is the difference between the paint() and repaint() methods?\n A: The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread."
},
{
"textToSpeech": "Q: What is the purpose of File class?\n A: It is used to create objects that provide access to the files and directories of a local file system."
},
{
"textToSpeech": "Q: What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?\n A: The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented."
},
{
"textToSpeech": "Q: Which class should you use to obtain design information about an object?\n A: The Class class is used to obtain information about an object's design and java.lang.Class class instance represent classes, interfaces in a running Java application."
},
{
"textToSpeech": "Q: What is the difference between static and non-static variables?\n A: A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance."
},
{
"textToSpeech": "Q: What is Serialization and deserialization?\n A: Serialization is the process of writing the state of an object to a byte stream. Deserialization is the process of restoring these objects."
},
{
"textToSpeech": "Q: What are use cases?\n A: It is part of the analysis of a program and describes a situation that a program might encounter and what behavior the program should exhibit in that circumstance."
},
{
"textToSpeech": "Q: Explain the use of sublass in a Java program?\n A: Sub class inherits all the public and protected methods and the implementation. It also inherits all the default modifier methods and their implementation."
},
{
"textToSpeech": "Q: How to add menushortcut to menu item?\n A: If there is a button instance called b1, you may add menu short cut by calling b1.setMnemonic('F'), so the user may be able to use Alt+F to click the button."
},
{
"textToSpeech": "Q: Can you write a Java class that could be used both as an applet as well as an application?\n A: Yes, just add a main() method to the applet."
},
{
"textToSpeech": "Q: What is the difference between Swing and AWT components?\n A: AWT components are heavy-weight, whereas Swing components are lightweight. Heavy weight components depend on the local windowing toolkit. For example, java.awt.Button is a heavy weight component, when it is running on the Java platform for Unix platform, it maps to a real Motif button."
},
{
"textToSpeech": "Q: What's the difference between constructors and other methods?\n A: Constructors must have the same name as the class and can not return a value. They are only called once while regular methods could be called many times."
},
{
"textToSpeech": "Q: Is there any limitation of using Inheritance?\n A: Yes, since inheritance inherits everything from the super class and interface, it may make the subclass too clustering and sometimes error-prone when dynamic overriding or dynamic overloading in some situation."
},
{
"textToSpeech": "Q: When is the ArrayStoreException thrown?\n A: When copying elements between different arrays, if the source or destination arguments are not arrays or their types are not compatible, an ArrayStoreException will be thrown."
},
{
"textToSpeech": "Q: Can you call one constructor from another if a class has multiple constructors?\n A: Yes, use this() syntax."
},
{
"textToSpeech": "Q: What's the difference between the methods sleep() and wait()?\n A: The code sleep(2000); puts thread aside for exactly two seconds. The code wait(2000), causes a wait of up to two second. A thread could stop waiting earlier if it receives the notify() or notifyAll() call. The method wait() is defined in the class Object and the method sleep() is defined in the class Thread."
},
{
"textToSpeech": "Q: When ArithmeticException is thrown?\n A: The ArithmeticException is thrown when integer is divided by zero or taking the remainder of a number by zero. It is never thrown in floating-point operations."
},
{
"textToSpeech": "Q: What is a transient variable?\n A: A transient variable is a variable that may not be serialized during Serialization and which is initialized by its default value during de-serialization,"
},
{
"textToSpeech": "Q: What is synchronization?\n A: Synchronization is the capability to control the access of multiple threads to shared resources. synchronized keyword in java provides locking which ensures mutual exclusive access of shared resource and prevent data race."
},
{
"textToSpeech": "Q: What is the Collections API?\n A: The Collections API is a set of classes and interfaces that support operations on collections of objects."
},
{
"textToSpeech": "Q: Does garbage collection guarantee that a program will not run out of memory?\n A: Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection."
},
{
"textToSpeech": "Q: The immediate superclass of the Applet class?\n A: Panel is the immediate superclass. A panel provides space in which an application can attach any other component, including other panels."
},
{
"textToSpeech": "Q: Which Java operator is right associative?\n A: The = operator is right associative."
},
{
"textToSpeech": "Q: What is the difference between a break statement and a continue statement?\n A: A break statement results in the termination of the statement to which it applies (switch, for, do, or while). A continue statement is used to end the current loop iteration and return control to the loop statement."
},
{
"textToSpeech": "Q: If a variable is declared as private, where may the variable be accessed?\n A: A private variable may only be accessed within the class in which it is declared."
},
{
"textToSpeech": "Q: What is the purpose of the System class?\n A: The purpose of the System class is to provide access to system resources."
},
{
"textToSpeech": "Q: List primitive Java types?\n A: The eight primitive types are byte, char, short, int, long, float, double, and boolean."
},
{
"textToSpeech": "Q: What is the relationship between clipping and repainting under AWT?\n A: When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting."
},
{
"textToSpeech": "Q: Which class is the immediate superclass of the Container class?\n A: Component class is the immediate super class."
},
{
"textToSpeech": "Q: What class of exceptions are generated by the Java run-time system?\n A: The Java runtime system generates RuntimeException and Error exceptions."
},
{
"textToSpeech": "Q: Under what conditions is an object's finalize() method invoked by the garbage collector?\n A: The garbage collector invokes an object's finalize() method when it detects that the object has become unreachable."
},
{
"textToSpeech": "Q: How can a dead thread be restarted?\n A: A dead thread cannot be restarted."
},
{
"textToSpeech": "Q: Which arithmetic operations can result in the throwing of an ArithmeticException?\n A: Integer / and % can result in the throwing of an ArithmeticException."
},
{
"textToSpeech": "Q: Variable of the boolean type is automatically initialized as?\n A: The default value of the boolean type is false."
},
{
"textToSpeech": "Q: Can try statements be nested?\n A: Yes"
},
{
"textToSpeech": "Q: What is Nested top-level class?\n A: If a class is declared within a class and specify the static modifier, the compiler treats the class just like any other top-level class. Nested top-level class is an Inner class."
},
{
"textToSpeech": "Q: What is Externalizable interface?\n A: Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism."
},
{
"textToSpeech": "Q: If System.exit (0); is written at the end of the try block, will the finally block still execute?\n A: No in this case the finally block will not execute because when you say System.exit (0); the control immediately goes out of the program, and thus finally never executes."
},
{
"textToSpeech": "Q: What is daemon thread?\n A: Daemon thread is a low priority thread, which runs intermittently in the back ground doing the garbage collection operation for the java runtime system."
},
{
"textToSpeech": "Q: Which method is used to create the daemon thread?\n A: setDaemon method is used to create a daemon thread."
},
{
"textToSpeech": "Q: Which method must be implemented by all threads?\n A: All tasks must implement the run() method"
},
{
"textToSpeech": "Q: What is the GregorianCalendar class?\n A: The GregorianCalendar provides support for traditional Western calendars"
},
{
"textToSpeech": "Q: What is the SimpleTimeZone class?\n A: The SimpleTimeZone class provides support for a Gregorian calendar ."
},
{
"textToSpeech": "Q: What is the difference between the size and capacity of a Vector?\n A: The size is the number of elements actually stored in the vector, while capacity is the maximum number of elements it can store at a given instance of time."
},
{
"textToSpeech": "Q: Can a vector contain heterogenous objects?\n A: Yes a Vector can contain heterogenous objects. Because a Vector stores everything in terms of Object."
},
{
"textToSpeech": "Q: What is an enumeration?\n A: An enumeration is an interface containing methods for accessing the underlying data structure from which the enumeration is obtained. It allows sequential access to all the elements stored in the collection."
},
{
"textToSpeech": "Q: What is difference between Path and Classpath?\n A: Path and Classpath are operating system level environment variales. Path is defines where the system can find the executables(.exe) files and classpath is used to specify the location of .class files."
},
{
"textToSpeech": "Q: Can a class declared as private be accessed outside it's package?\n A: No, it's not possible to accessed outside it's package."
},
{
"textToSpeech": "Q: What are the restriction imposed on a static method or a static block of code?\n A: A static method should not refer to instance variables without creating an instance and cannot use this operator to refer the instance."
},
{
"textToSpeech": "Q: Can an Interface extend another Interface?\n A: Yes an Interface can inherit another Interface, for that matter an Interface can extend more than one Interface."
},
{
"textToSpeech": "Q: Which object oriented Concept is achieved by using overloading and overriding?\n A: Polymorphism"
},
{
"textToSpeech": "Q: What is an object's lock and which object's have locks?\n A: An object's lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object's lock."
},
{
"textToSpeech": "Q: What is Downcasting?\n A: It is the casting from a general to a more specific type, i.e. casting down the hierarchy."
},
{
"textToSpeech": "Q: What are order of precedence and associativity and how are they used?\n A: Order of precedence determines the order in which operators are evaluated in expressions. Associatity determines whether an expression is evaluated left-to-right or right-to-left."
},
{
"textToSpeech": "Q: If a method is declared as protected, where may the method be accessed?\n A: A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared."
},
{
"textToSpeech": "Q: What is the difference between inner class and nested class?\n A: When a class is defined within a scope of another class, then it becomes inner class. If the access modifier of the inner class is static, then it becomes nested class."
},
{
"textToSpeech": "Q: What restrictions are placed on method overriding?\n A: Overridden methods must have the same name, argument list, and return type. The overriding method may not limit the access of the method it overrides."
},
{
"textToSpeech": "Q: What is constructor chaining and how is it achieved in Java?\n A: A child object constructor always first needs to construct its parent. In Java it is done via an implicit call to the no-args constructor as the first statement."
},
{
"textToSpeech": "Q: Can a double value be cast to a byte?\n A: Yes, a double value can be cast to a byte."
},
{
"textToSpeech": "Q: How does a try statement determine which catch clause should be used to handle an exception?\n A: When an exception is thrown within the body of a try statement, the catch clauses of the try statement are examined in the order in which they appear. The first catch clause that is capable of handling the exception is executed. The remaining catch clauses are ignored."
},
{
"textToSpeech": "Q: What is the range of the short type?\n A: The range of the short type is -(2^15) to 2^15 - 1."
},
{
"textToSpeech": "Q: What is the immediate superclass of Menu?\n A: MenuItem class"
},
{
"textToSpeech": "Q: Does Java allow Default Arguments?\n A: No, Java does not allow Default Arguments."
},
{
"textToSpeech": "Q: Which number is denoted by leading zero in java?\n A: Octal Numbers are denoted by leading zero in java, example: 06"
},
{
"textToSpeech": "Q: Which number is denoted by leading 0x or 0X in java?\n A: Hexadecimal Numbers are denoted by leading 0x or 0X in java, example: 0XF"
},
{
"textToSpeech": "Q: Break statement can be used as labels in Java?\n A: Yes, an example can be break one;"
},
{
"textToSpeech": "Q: Where import statement is used in a Java program?\n A: Import statement is allowed at the beginning of the program file after package statement."
},
{
"textToSpeech": "Q: Explain suspend() method under Thread class>\n A: It is used to pause or temporarily stop the execution of the thread."
},
{
"textToSpeech": "Q: Explain isAlive() method under Thread class?\n A: It is used to find out whether a thread is still running or not."
},
{
"textToSpeech": "Q: What is currentThread()?\n A: It is a public static method used to obtain a reference to the current thread."
},
{
"textToSpeech": "Q: Explain main thread under Thread class execution?\n A: The main thread is created automatically and it begins to execute immediately when a program starts. It ia thread from which all other child threads originate."
},
{
"textToSpeech": "Q: Life cycle of an applet includes which steps?\n A: Life cycle involves the following steps:\n • Initialization\n • Starting\n • Stopping\n • Destroying\n • Painting"
},
{
"textToSpeech": "Q: Why is the role of init() method under applets?\n A: It initializes the applet and is the first method to be called."
},
{
"textToSpeech": "Q: Which method is called by Applet class to load an image?\n A: getImage(URL object, filename) is used for this purpose."
},
{
"textToSpeech": "Q: Define code as an attribute of Applet?\n A: It is used to specify the name of the applet class."
},
{
"textToSpeech": "Q: Define canvas?\n A: It is a simple drawing surface which are used for painting images or to perform other graphical operations."
},
{
"textToSpeech": "Q: Define Network Programming?\n A: It refers to writing programs that execute across multiple devices (computers), in which the devices are all connected to each other using a network."
},
{
"textToSpeech": "Q: What is a Socket?\n A: Sockets provide the communication mechanism between two computers using TCP. A client program creates a socket on its end of the communication and attempts to connect that socket to a server."
},
{
"textToSpeech": "Q: Advantages of Java Sockets?\n A: Sockets are flexible and sufficient. Efficient socket based programming can be easily implemented for general communications. It cause low network traffic."
},
{
"textToSpeech": "Q: Disadvantages of Java Sockets?\n A: Socket based communications allows only to send packets of raw data between applications. Both the client-side and server-side have to provide mechanisms to make the data useful in any way."
},
{
"textToSpeech": "Q: Which class is used by server applications to obtain a port and listen for client requests?\n A: java.net.ServerSocket class is used by server applications to obtain a port and listen for client requests"
},
{
"textToSpeech": "Q: Which class represents the socket that both the client and server use to communicate with each other?\n A: java.net.Socket class represents the socket that both the client and server use to communicate with each other."
},
{
"textToSpeech": "Q: Why Generics are used in Java?\n A: Generics provide compile-time type safety that allows programmers to catch invalid types at compile time. Java Generic methods and generic classes enable programmers to specify, with a single method declaration, a set of related methods or, with a single class declaration, a set of related types."
},
{
"textToSpeech": "Q: What environment variables do I need to set on my machine in order to be able to run Java programs?\n A: CLASSPATH and PATH are the two variables."
},
{
"textToSpeech": "Q: Is there any need to import java.lang package?\n A: No, there is no need to import this package. It is by default loaded internally by the JVM."
},
{
"textToSpeech": "Q: What are ClassLoaders?\n A: A class loader is an object that is responsible for loading classes. The class ClassLoader is an abstract class."
},
{
"textToSpeech": "Q: What is the difference between an Interface and an Abstract class?\n A: An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation."
},
{
"textToSpeech": "Q: What will happen if static modifier is removed from the signature of the main method?\n A: Program throws NoSuchMethodError error at runtime ."
},
{
"textToSpeech": "Q: What is the default value of an object reference declared as an instance variable?\n A: Null, unless it is defined explicitly."
},
{
"textToSpeech": "Q: Can a top level class be private or protected?\n A: No, a top level class can not be private or protected. It can have either public or no modifier."
},
{
"textToSpeech": "Q: Why do we need wrapper classes?\n A: We can pass them around as method parameters where a method expects an object. It also provides utility methods."
},
{
"textToSpeech": "Q: What is the difference between error and an exception?\n A: An error is an irrecoverable condition occurring at runtime.Such as OutOfMemory error. Exceptions are conditions that occur because of bad input etc. e.g. FileNotFoundException will be thrown if the specified file does not exist."
},
{
"textToSpeech": "Q: Is it necessary that each try block must be followed by a catch block?\n A: It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block or a finally block."
},
{
"textToSpeech": "Q: When a thread is created and started, what is its initial state?\n A: A thread is in the ready state as initial state after it has been created and started."
},
{
"textToSpeech": "Q: What is the Locale class?\n A: The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region."
},
{
"textToSpeech": "Q: What are synchronized methods and synchronized statements?\n A: Synchronized methods are methods that are used to control access to an object. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement."
},
{
"textToSpeech": "Q: What is runtime polymorphism or dynamic method dispatch?\n A: Runtime polymorphism or dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile-time. In this process, an overridden method is called through the reference variable of a superclass."
},
{
"textToSpeech": "Q: What is Dynamic Binding(late binding)?\n A: Binding refers to the linking of a procedure call to the code to be executed in response to the call. Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run-time."
},
{
"textToSpeech": "Q: Can constructor be inherited?\n A: No, constructor cannot be inherited."
},
{
"textToSpeech": "Q: What are the advantages of ArrayList over arrays?\n A: ArrayList can grow dynamically and provides more powerful insertion and search mechanisms than arrays."
},
{
"textToSpeech": "Q: Why deletion in LinkedList is fast than ArrayList?\n A: Deletion in linked list is fast because it involves only updating the next pointer in the node before the deleted node and updating the previous pointer in the node after the deleted node."
},
{
"textToSpeech": "Q: How do you decide when to use ArrayList and LinkedList?\n A: If you need to frequently add and remove elements from the middle of the list and only access the list elements sequentially, then LinkedList should be used. If you need to support random access, without inserting or removing elements from any place other than the end, then ArrayList should be used."
},
{
"textToSpeech": "Q: What is a Values Collection View ?\n A: It is a collection returned by the values() method of the Map Interface, It contains all the objects present as values in the map."
},
{
"textToSpeech": "Q: What is dot operator?\n A: The dot operator(.) is used to access the instance variables and methods of class objects.It is also used to access classes and sub-packages from a package."
},
{
"textToSpeech": "Q: Where and how can you use a private constructor?\n A: Private constructor is used if you do not want other classes to instantiate the object and to prevent subclassing."
},
{
"textToSpeech": "Q: What is type casting?\n A: Type casting means treating a variable of one type as though it is another type."
},
{
"textToSpeech": "Q: Describe life cycle of thread?\n A: A thread is a execution in a program. The life cycle of a thread include:\n • Newborn state\n • Runnable state\n • Running state\n • Blocked state\n • Dead state"
},
{
"textToSpeech": "Q: What is the difference between the >> and >>> operators?\n A: The >> operator carries the sign bit when shifting right. The >>> zero-fills bits that have been shifted out."
},
{
"textToSpeech": "Q: Which method of the Component class is used to set the position and size of a component?\n A: setBounds() method is used for this purpose."
},
{
"textToSpeech": "Q: What will be the default values of all the elements of an array defined as an instance variable?\n A: If the array is an array of primitive types, then all the elements of the array will be initialized to the default value corresponding to that primitive type."
},
{
"textToSpeech": "Q: List any five features of Java?\nA: Some features include Object Oriented, Platform Independent, Robust, Interpreted, Multi-threaded"
}
]
},
{
"type": "suggestion_chips",
"platform": "google",
"suggestions": [
{
"title": "Developer"
},
{
"title": "More Java Questions"
},
{
"title": "Exit"
}
],
"lang": "en"
},
{
"type": 0,
"speech": []
}
],
"defaultResponsePlatforms": {
"google": true
},
"speech": []
}
],
"priority": 500000,
"cortanaCommand": {
"navigateOrService": "NAVIGATE",
"target": ""
},
"webhookUsed": false,
"webhookForSlotFilling": false,
"lastUpdate": 1536822663,
"fallbackIntent": false,
"events": [],
"userSays": [
{
"id": "48d6a7a1-06eb-4a4e-87f1-2ef887765075",
"data": [
{
"text": "another question on java"
}
],
"isTemplate": false,
"count": 1,
"updated": 1535845356,
"isAuto": false
},
{
"id": "04f4f225-08b7-4df0-a3b8-a2ace5bdc347",
"data": [
{
"text": "more java questions"
}
],
"isTemplate": false,
"count": 0,
"updated": 1536452903,
"isAuto": false
},
{
"id": "19407dd1-f022-4b1c-b740-8541ba8821c3",
"data": [
{
"text": "tell me something about java?"
}
],
"isTemplate": false,
"count": 1,
"updated": 1535845356,
"isAuto": false
},
{
"id": "9859e7f2-06c7-445a-93b6-784c4ebe774a",
"data": [
{
"text": "What do you know about Java?"
}
],
"isTemplate": false,
"count": 0,
"updated": 1535845356,
"isAuto": false
},
{
"id": "283629ce-1aa1-4cd0-8b32-2a45f436047d",
"data": [
{
"text": "next"
}
],
"isTemplate": false,
"count": 0,
"updated": 1536452903,
"isAuto": false
},
{
"id": "a40029fd-d498-4152-92fd-fc96d2fa64d4",
"data": [
{
"text": "java interview questions, please?"
}
],
"isTemplate": false,
"count": 0,
"updated": 1535845356,
"isAuto": false
},
{
"id": "cc71e4f5-a77d-42af-b15c-21450c147f27",
"data": [
{
"text": "more questions"
}
],
"isTemplate": false,
"count": 0,
"updated": 1536452903,
"isAuto": false
},
{
"id": "3042ece0-e2ce-4802-8901-00683f49f902",
"data": [
{
"text": "another question of java"
}
],
"isTemplate": false,
"count": 0,
"updated": 1535845356,
"isAuto": false
},
{
"id": "aa548477-5a58-4b15-a67f-492432ede7b1",
"data": [
{
"text": "java"
}
],
"isTemplate": false,
"count": 0,
"updated": 1535845356,
"isAuto": false
},
{
"id": "dac83287-b0e4-4b20-93d2-5a2618f5b693",
"data": [
{
"text": "Java interview questions?"
}
],
"isTemplate": false,
"count": 0,
"updated": 1535845356,
"isAuto": false
}
],
"followUpIntents": [],
"liveAgentHandoff": false,
"endInteraction": false,
"templates": []
}