OBJECT ORIENTED PROGRAMMING
NEED OF OOP S o Programs are written around two concepts: What is happening Who is being Affected o The first approach is used in C which makes it complex. It is called Process Oriented model. o The second approach is Object Oriented Programming which is used by Java to manage the growing complexities ofa program
INTRODUCTION TO OOP S o The most fundamental concept of OOP's is Abstraction which is a powerful methodology to manage complex systems. o For example this abstraction helps us to drive a car to a grocery store without being bothered about the complexity of parts in the car. For the user from outside the car is only a single object. o The properties of OOP's are: Inheritance Polymorphism Encapsulation
ABSTRACTION The process of hiding implementation details from the user, only the functionality is provided to the user. In Java Abstraction is achieved by using the class containing abstract keyword. If a class has atleast one abstract method then the class must be declared abstract. Abstract classes may or not contain abstract method If a class is declared abstract it cannot be instantiated. lo use an abstract class we need to 1nhent from another class. If you inherit an abstract clas you have to provide implementations to all the abstract methods.
EXAMPLE PROGRAM abstract class Shape! abstract void draw(0) ngle extends Shape class Rectangle extends Shape void draw() System.out.printine drawing rectangle" System.out.println("drawing rectangle");3 class TestAbstraction public static void main(String args[l) Shape obj-new Shape); obj.draw(0:
Hey everyone,I am Kshethra. I really love explaining to someone it somehow turned up to my passion.I'm really happy to fulfill my passion .