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: Java Version Specific.txt
+80-2Lines changed: 80 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ Java 5 specifics
20
20
21
21
It is a generic type that is parametrized with an unbounded ( <?> ) or bounded ( <? extends T> ot <? super T> ) wildcard type. A wildcard type basically tells us that the type parameter can be any type.
22
22
23
-
4. What is Autoboxing/unboxing and what are its advantages/pitfalls?
23
+
4. What is Autoboxing/unboxing?
24
24
25
25
Autoboxing is automatic casting of variables of primitive types to corresponding wrapper class. Unboxing is the inverted cast.
26
26
Useful to reduce the amount of code to be written. Pitfalls: can be unintentionally slow if used in a loop. Also care has to be taken with cached values. (e.g. a pool of Integers from -128 to +127)
@@ -34,24 +34,102 @@ Java 5 specifics
34
34
5. Enables to associate additional data with enum constants
35
35
36
36
6. What are Annotations and which predefined by the language specification does one know (@Deprecated, @Override, @SuppressWarnings)
37
+
38
+
From http://docs.oracle.com/javase/tutorial/java/javaOO/annotations.html
39
+
Annotations provide data about a program that is not part of the program itself. They have no direct effect on the operation of the code they annotate. Annotations can be applied to a program's declarations of classes, fields, methods, and other program elements.
37
40
38
41
@Deprecated -- to inform that the method is deprecated
39
42
@Override -- to inform that this method has to override a method in a superclass. Helps to find errors.
40
43
@SuppressWarnings -- to suppress warnings. E.g. warnings generated when doing potentially unsafe cast
41
44
42
45
16. Annotation retentions policies and why they are in place?
43
46
44
-
TODO: ...
47
+
The retention policies specify how long annotations are to retained.
48
+
49
+
CLASS: Annotations are to be recorded in the class file by the compiler but need not be retained by the VM at run time. Useful for bytecode postprocessing. Cannot be inspected at run-time with reflection getAnnotations
50
+
51
+
RUNTIME: Annotations are to be recorded in the class file by the compiler and retained by the VM at run time, so they may be read reflectively. (@Deprecated)
52
+
53
+
SOURCE: Annotations are to be discarded by the compiler. (Example: @Override, @SuppressWarnings)
45
54
46
55
17. Suppose you would like to reuse a class in different contexts would you use annotations or external configuration? (i.e. annotation introduce dependencies).
56
+
57
+
Good discussion of this question can be found here
The try-with-resources statement is a try statement that declares one or more resources. A resource is an object that must be closed after the program is finished with it. The try-with-resources statement ensures that each resource is closed at the end of the statement. Any object that implements java.lang.AutoCloseable, which includes all objects which implement java.io.Closeable, can be used as a resource.
Note that these exceptions cannot belong to the same hierarchy (none is subclass or superclass of the other)
97
+
54
98
4. Strings in switch statement
99
+
100
+
String dayOfWeek = "Mon";
101
+
switch (dayOfWeek.toLowerCase()) {
102
+
case "mon" :
103
+
//do something
104
+
break;
105
+
case "tue" :
106
+
//do something
107
+
break;
108
+
...
109
+
default :
110
+
//do something
111
+
break;
112
+
}
113
+
55
114
5. Numeric literals with underscores
115
+
116
+
From http://docs.oracle.com/javase/7/docs/technotes/guides/language/underscores-literals.html
117
+
In Java SE 7 and later, any number of underscore characters (_) can appear anywhere between digits in a numerical literal. This feature enables you, for example, to separate groups of digits in numeric literals, which can improve the readability of your code
The fork / join framework is an implementation of the ExecutorService interface that helps you take advantage of multiple processors. It is designed for work that can be broken into smaller pieces recursively.
0 commit comments