OOPs Concepts


OOPs Concepts

  1.  An object is an instance of a class
  2. Object is a bundle of data and its methods (often called methods)
  3. Example: 

  4. class House {
       String address;
       String color;
       double are;
       void openDoor() {
          //Write code here
       }
       void closeDoor() {
          //Write code here
       }
     ...
     ...
    }
  5. Abstraction: is the process where you only show "relevant " data and hide the "unnecessary" data from the user accessing the object. When you login to online banking, the only data shown to you is the username and password fields. The process of data transfer is hidden.
  6. Encapsulation: means binding object states (fields) and behaviors (methods) together. If you are creating a class, you are encapsulating. (Getters and Setters, making variables private etc.)
  7. Inheritance: means inheriting the properties and functionalities of another class. Is used for code re-usability
  8. Polymorphism: lets you to define a particular function is different ways. (Method overloading and method overriding)
  9. Abstract class: means having methods which is declared but not defined. This allows the child classes to declare these methods before using them.
  10. Interfaces: is the blueprint of a class. It is used to declare constants and abstract methods. They cannot be instantiated or defined. It is used to achieve full abstraction in Java.
  11. Access specifiers: include public, private, protected, default keywords which define the scope of a data member.

Popular posts from this blog

Building your first Phonegap android application with HTML and JavaScript