Abstract class and methods is many time uses in java programs when we want to create indexing of our methods in some secure class.
Why Abstract class is secure?
– We can’t create an object of Abstract Class, so we have to inheritance abstract with sub class. So, all access of abstract classes is managed by sub class. We can’t directly access from main class.
Rules of Abstract Class
– Can’t create an object of abstract classes
– Must be inheritance
– abstract methods must be in abstract classes
– abstract methods only declare in abstract classes, must be override in sub class
Example on Abstract classes and methods
abstract class A
abstract void methodA(); // Dec of method – Indexing
System.out.println(“Welcome in Normal Method”);
class B extends A
System.out.println(“Welcome in Abstract Class’s Method”);
public static void main(String args)
// A obj = new A(); // Create an Error
B obj = new B();
obj.methodA(); // call to overide method
obj.normalMethod(); // call to inheritance class method
Welcome in Abstract Class’s Method
Welcome in Normal Method
Video available on YouTube.
If you have any query on blog example, you can directly comment us or subscribe our website
Share and Enjoy
472total visits,2visits today