Core Java Basics
1. static
variable  
void fun(){
static int m = 22;
  //wrond
System.out.println();
}
static variable
cannot be declared bcz it is class level and jvm do not allow to keep
multiple copy of variable whic is being used by other mehtods.
- Static variable
can be used with object or without object.
- Static variable
can used within non-static mehtod as well as in static method.
2. Constructor 
- If any method have same name as class have with return type,
then it will not treated as constructor of class.
- constructor do not return anything.
- If class have private constructor and no other public constructor,
then that class cannot be instantiate.
3. Inner Class
- Inner used when multiple class used by single class.
- Used where many event occur in single window.
4. Static class
class A{
 static class B{
}
}
- private access MODIFIER is not ASSOCIETED WITH CLASS
-
instances
of this class
cannot
be created. 
-
Static
classes are
sealed and therefore cannot be inherited.
-
Static
class defined within another class.
-
If
you want define another static class within another class which is
already inner class then that inner class should be static
class
A{.......
.
.
 static
class B{
  static
class C{
  }
  }
}
-
 To
acces static class for above example
    B
b = new B();
    B.C
c = new C();   
5.
Static
Block
-
static{
}
-
It is defined within class.
-
Code written in this block get execute automatically, do not require
to call it.
-
 A clas can have many statuc blocks.
6.
Static
Method
- Static method cannot overrid in child class.
7. Anonymous
Class
-
An inner class declared without a class name is known as an anonymous
inner class.
-
In case of anonymous inner classes, we declare
and instantiate them at the same
time.
-
 Generally, they are used whenever you need to override the method of
a class or an interface.
Syntax:-
className
a = new className(){
    //Anymethod
};
7.
Functional Interface
-
An interface which has only one
abstract method.
-
Lambda
expression provides implementation of functional
interface
-
Java
provides an anotation @FunctionalInterface,
which is used to declare an interface as functional interface.
8.
Lambda function
-
To
provide the implementation of Functional interface.
-
Less
coding.
Syntax
ClassName
c = ()->{
};
9.
Super Keyword
-
Use
to invoke constructor of immediate parent class.
-
Use to invoke variable of immediate parent class.
-
Use to invokde method sof
immediate parent class.
10.
this keyword
-
refer to current instance of class.
-
invoke variable of current class.
-
invoke method
of class.
-
 reference to object of current class
11.
HashSet
-
HashSet use HashTable to store data.
-
It inherist AbstractSet and Set interface.
-
It use hashing technique to store data.
-
It does not conatain duplicates values.
12.
LinkedHashSet
-
 It
is same like HashSet.
-
It maintain insertion Order.
-
Ordered
13.
HashMap
Java
HashMap class implements the map interface by using a hashtable. It
inherits AbstractMap class and implements Map interface.
-
Contain Unique value
-
May contain one or many null value.
-
Maintain no order.
14.
HashTable
-
HashTable
class implement hastable, which map values with key.
-
A
HashTable is array of list. Each list is known as bucket.
-
It conatains
conly
unique
value.
-
It is
synchronized.
15.
HashMap Vs. HashTable
16.
TreeSet
Java
TreeSet class implements the Set interface that uses
a tree for storage.
It inherits AbstractSet class and implements NavigableSet interface.
The objects
of TreeSet class are stored in ascending order.
-
Unique element
-
 Access and retreive times fast.
-
Maintain ascending order.
17.
TreeHashMap
Java
TreeMap class implements the Map interface by using
a tree.
It provides an efficient means of storing key/value pairs in sorted
order.
-
It
cannot have null key but can have multiple null values.
-
It is same as HashMap instead maintains ascending order.
-
Contains
Unique
element
 
Comments
Post a Comment