Youtube Channel

Java Points to remember

1) Java characters are Unicode .
2) Size of an int type is 32 bits
3) The default value of Boolean type is false
4) All operands are evaluated left to right
5) A private modifier applied for methods and variables not for the top level classes
6) Abstract modifier cannot be applied to variable and constructor
7) A static class can access static variables of the enclosing class
8) The default priority of thread is 5
9) An inner class cannot declare static variables
10) We cannot put two top level public classes into the same source file
11) Methods can have the same name as the constructors
12) The main() cannot call the non static methods
13) We cannot access non final variables from the local classes
14) Java.lang.Math is an immutable class hence it cannot be sub classed
15) instaceOf and instanceof are not same
16) we can use private modifier for constructors
17) The main() can be declared as final (Ex:- final public static void main(String args[]))
18) -0.0==0.0 is true
19) We can declare a class without abstract methods can still be declared as abstract
20) The Map does not implement Collection interface
21) Collection is an interface Collections is a class don’t confuse
22) Dictionary is a class not an interface
23) Strings are initialized to null not for the empty string
24) Empty string and null reference both are not same
25) Continue must be in loops
26) Constructor can throw exception
27) Initialize blocks are executed in the order of declaration
28) Instance initializers are executed when the object is constructed for that class
29) The equals() returns false if the object types are different it does not raise any compile time error
30) InputStream and OutputStream are the abstract classes
31) Byte,Short,Integer,Long,Float,Double,Character,Boolean are wrapper classes in java
32) We cannot override final methods in sub classes
33) String is an immutable class
34) Identifiers can begin with letters ,underscore, currency characters not with numbers
35) A source file can have more than one nonpublic class
36) The access modifiers are public,private,protected
37) There are four access levels those are public ,private,protected,default
38) Classes can contain only public or default access
39) If a class declared by default we can access only within the same package
40) If a class declared with public we can access from any where of the application
41) The non access modifiers are final,abstact,strictfp
42) We cannot declare class with both final ,abstract
43) We cannot create object to abstract class
44) If a class contain single abstract method we should declare that class as abstract
45) We can have both abstract and non abstract(Implemented) methods in abstract class
46) Interface is an 100% abstract class it can have only abstract methods concrete methods are not allowed
47) In interface methods are by default public and abstract
48) We can have constants in interface by default those are public,static,final
49) Any class can implement the interface
50) We should provide implementation for all methods in interface in our implemented class
51) A class can extend only one class but can implement many interfaces
52) Interface can extend one or more interfaces, and interfaces cannot extend a class or implement a class or interface
53) In java methods and members we can call it as members
54) Members accessed without dot (.) operator must belongs to the same class
55) this keyword always refers currently executing object
56) private members we can access with in the class only
57) protected members can accessed by the other classes in the same package and we can also access by inheritance in other packages
58) Only we can declare local variables with final modifiers
59) Instance variables initialized with their default values
60) Local variables do not get default values, So we must initialize before using them
61) Abstract methods end with (;) not with curly braces
62) The synchronized modifier can only applies to methods and code blocks
63) Synchronized methods can have any access control and we can also place final
64) Abstract methods cannot be private and final
65) The native modifier only applies for methods
66) The strictfp modifier only applies to classes and methods
67) Instance variables cannot be abstract, synchronized, native or strictfp
68) We cannot change final variable values once we initialized
69) The transient ,volatile modifier applies to only instance variables
70) A constructor invoked when new object is created
71) Constructor name must be class name
72) Java compiler will create default constructor if we don’t create
73) Constructors are never inherited so, we cannot be overridden
74) The first statement of every constructor must be a call to either this() or super()
75) Interfaces don’t have constructors
76) We can call one constructor form other constructor by using this() or super()
77) We cannot put both this() and super() in same constructor
78) All static members are related to class level not to the object level
79) Local variables are stored in stack
80) Objects and their instance variables stored in heap
81) Static variables live basically as long as their class lives
82) Instance variable lives as long as their object lives
83) Local variables live as long as their method is on the stack
84) Block level variables live until the block completes
85) new keyword is used to create objects
86) Arrays can hold primitives or objects
87) You must include the size of an array when construct by using new keyword unless you are creating
anonymous array.
88) Arrays are indexed beginning with zero
89) When we use wrong index value we will get ArrayIndexOutOfBoundsException
90) The purpose of garbage collector is delete the unused objects
91) JVM will decide when to run garbage collector and we can only suggest
92) Switch statements can evaluate only enums or byte,short,int and char data types
93) String objects are immutable but string references are not
94) == used to compare the object references
95) .equals() method is used to compare the object contents
96) We can override equals(), hashCode(), toString() methods they are public
97) ArrayList is good for fast random access and fast iteration
98) Vector is slower than the ArrayList but it contains synchronized methods
99) LinkedList is good for adding the elements end to end
100) HashSet for fast access and it don’t contain duplicates and provides no ordering
101) LinkedHashSet will not allow duplications and iterates by insertion order
102) TreeSet will not allow duplicates iterates in sorted order
103) HashMap provides fastest updates and it allows on null key any many null values
104) Hashtable slower than HashMap and it is synchronized and will not allow null keys and null values
105) LinkedHashMap for faster iterations iterates by insertion order or last accessed allows one null key and many null values
106) Collections hold only objects , But primitives can autoboxed
107) Static methods can execute without main() method upto 1.6 but from 1.7 we must need main()
Next PostNewer Post Previous PostOlder Post Home

0 comments: