You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -558,6 +558,8 @@ It is also a good practice to annotate overridden methods with `@Override` to ma
558
558
j =10; // Instantiated variable
559
559
```
560
560
*When is a `static` block run?
561
+
-Code inside static block is executed only once: the first time you make an object of that classor the first time you access a static member of that class (even if you never make an object of that class).
562
+
561
563
* Explain Generics in Java?
562
564
- Generics were included in Java language to provide stronger type checks, by allowing the programmer to define, which classes can be used with other classes
563
565
> In a nutshell, generics enable types (classes and interfaces) to be parameters when defining classes, interfaces and methods. Much like the more familiar formal parameters used in method declarations, type parameters provide a way for you to re-use the same code with different inputs. The difference is that the inputs to formal parameters are values, while the inputs to type parameters are types. ([Official Java Documentation](https://docs.oracle.com/javase/tutorial/java/generics/why.html))
@@ -569,11 +571,11 @@ It is also a good practice to annotate overridden methods with `@Override` to ma
569
571
And let the compiler take care of noticing, if you put some object, of type other than `Integer` into this list and warn you.
570
572
- It should be noted that standard classhierarchy *does not* apply to generic types. It means that `Integer` in `List<Integer>` is not inherited from `<Number>` - it is actually inherited directly from `<Object>`. You can still put some constraints on what classes can be passed as a parameter into a generic by using [wildcards](https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html) like `<?>`, `<? extends MyCustomClass>` or `<? super Number>`.
571
573
- While generics are very useful, late inclusion into Java language has put some restraints on their implementation - backward compatibility required them to remain just "syntactic sugar" - they are erased ([type erasure](https://docs.oracle.com/javase/tutorial/java/generics/erasure.html)) during compile-time and replaced with `object` class.
572
-
* Difference between `StringBuffer` and `StringBuilder`?
574
+
* Difference between `StringBuffer` and `StringBuilder`? [Link](http://www.journaldev.com/137/stringbuffer-vs-stringbuilder)
573
575
* How is a `StringBuilder` implemented to avoid the immutable string allocation problem?
574
576
* What is Autoboxing and Unboxing?
575
577
- Autoboxing and Unboxing is the process of automatic wrapping (putting in a box) and unwrapping (getting the value out) of primitive data types, that have "wrapper" classes. So `int` and `Integer` can (almost always) be used interchangeably in Java language, meaning a method `void giveMeInt(int i) { ... }` can take `int` as well as `Integer` as a parameter.
576
-
*What’s the difference between an Enumeration and an Iterator?
578
+
*What’s the difference between an Enumeration and an Iterator? [Link](http://javaconceptoftheday.com/differences-between-enumeration-vs-iterator-in-java/)
577
579
*What is the difference between fail-fast and fail safe in Java?
578
580
*What is JavaNIO? [Link](http://tutorials.jenkov.com/java-nio/index.html)
0 commit comments