super Keyword
- super keyword is use to access properties of super class.
- By Using super keyword you can access the methods, variables and constructor of super class.
- Super is not an object of super class.
- Every Constructor of sub class by default calls a super class default/no-parameter constructor.
- You can also call a super class constructor by using super keyword, but it must be called from constructor only and it has to be a first line in a constructor.
this keyword
- this keyword is use to access the properties of same class.
- By using this keyword you can access the methods, variables and constructor of same class.
- this is also consider as a current class object.
- By using this you can call constructor of same class, but constructor call must be inside another constructor only.
- Constructor calling must be a first line in a constructor.
static Keyword
- Static keyword is use to create class level variable and methods.
- Static can be use for class also, but static classes must be an inner class.
- Static variables and methods can be access outside class without class object and just by class name.
- Can Create a static block, which is mostly use to initialize the static variables.
- Static block execute at the time of class loading and it executes only once.
- Static block or static method cannot access non-static variable or method.
- Cannot use super and this keyword inside static block, class or inside static method.
final Keyword
- Final keyword is use to create a constants (value will fixed throughout the program).
- Can be a class, variable, method.
- Final variables can be instance or local variable.
- The value of final variable never change.
- Rules to assign value to a final variable.
- Must provide a value to a final variable.
- Final variable can be initialize at declaration time or inside every constructor of class or inside initializer block.
- Final class cannot be use as a super class. In-build final classes are String, System.
- Final methods cannot be override.
Join Telegram : Click Here
All Full Stack Java Study Material
Job’s For Fresher