Object Oriented Programming - A preliminary concept

What is object?
Object: Anything could be an object. Students could be an object of an school, employee could be object of an organization. Anything that have properties could be an object.
What is properties of an object?

Properties: If you think about Student as an object, then name, color, weight, number, email, mobile, subject any attribute of student is it’s properties.
Let’s consider the following class Student(Java):


public class Student{

    String name;

    int rollNo;

    String email;

    String homeTown;

    int mobileNo;

    public String getStudentName(){

        return name;

    }
}


Consider the following School class:
 
public class School{
    String schoolName;
    String code;
    String address;
    
    Student studentObject = new Student();
}
 

Here we’ve created an object of a Java class named studentObject using JAVA new keyword.
According to object oriented programming concept, now we can access all the properties and methods of Student class using the object studentObject.
In the following code we are calling a method getStudentName() of Student class using the object studentObject, what we have created earlier.


public class School{
    String schoolName;
    String code;
    String address;
    
    Student studentObject = new Student(); 
    String studentName = studentObject.getStudentName();
    System.out.println(studentName);
} 
 
 The above code will print Student's name from the variable studentName. 
 
According to the basic slogan of programming, "Less Memory, Less Costs Maximum Work" we need 
object oriented programming to maintain this.
 
OOP help us in the following aspects:
  • Reduce redundancy of codes 
  • Increase Readability of codes
  • Enhance Maintainability of codes
  • Ultimately makes our programs lighter and faster to execute

In the following diagram a bank's object have delineated one is Account object and
 another is Person object:





Comments