OOP using simple examples | Part 2 Polymorphism

In here we are going to explain 4 major OOP concepts in a simple way,

  1. Encapsulations
  2. Polymorphism
  3. Inheritance
  4. Abstraction 
Polymorphism

Image result for manager png 

    Simple explanation is one thing many forms. Okay, let's move on to our simple example.

There is a company called ABC. The CEO of ABC wants to update his company using new technology and therefore he called a meeting and asked them to update using technology. There were Marketing manager of ABC, HR manager of ABC and Finance manger of ABC, so they cant update their field in same way so according to the command they build their own way to implement this command.



    abstract class CeoOfABC{  
        public abstract void update();  
    }  
      
    class MarketingManager extends CeoOfABC{  
        public void update(){  
            System.out.println("Marketing Manager updated");  
        }  
    }  
      
    class HrManager extends CeoOfABC{  
        public void update(){  
            System.out.println("HR Manager updated");  
        }  
    }  
      
    class FinanceManager extends CeoOfABC{  
        public void update(){  
            System.out.println("Finance Manager updated");  
        }  
    }  
    class ABC{  
        static MarketingManager marketingManager = new MarketingManager();  
        static HrManager hrManager = new HrManager();  
        static FinanceManager financeManager = new FinanceManager();  
          
        public static void main(String args[]){  
            marketingManager.update();  
            hrManager.update();  
            financeManager.update();  
        }  
    }  







Comments

Popular Posts