Object oriented programming is about creating objects that contains both data and methods.

The aims of Object oriented programming is to implement real-world entities like inheritance, data hiding, polymorphism and encapsulations.

OOP helps to bind together the data and the functions that operates on them so, no other part of the code can access this data except that function.

package practice_14;
public class OOP
{
    public static class MyClass
    {
        private int integerVar = 10; //Data
        
        //Method
        public void value()
        {
            System.out.println("Value = "+ integerVar);
        }
    }
    public static void main(String[] args) 
    {
        MyClass obj1 = new MyClass();
        obj1.value();       
    }
    
}

Facebook Comments