Page 52 - iPro_trackGPT_V5_Class8
P. 52

All vehicles in the Vehicle class have similar behaviours such as driving and refuelling, and they
                  also share similar properties like colour, size, and number of wheels. Similarly, a class in Java
                  includes different types of objects that have comparable attributes and methods. Once a class
                  is defined, you can create many objects from it, such as various types of vehicles like cars, bikes,
                  and trucks.

                     FEATURES OF OOPS

                  Object-Oriented Programming (OOP) is a programming paradigm that uses objects, classes, and
                  methods to design and implement software. Some key features of OOPs are as follows:
                     Encapsulation: Encapsulation is the concept of bundling the data (attributes) and the methods
                     (functions) that operate on the data into a single unit, called a class. It restricts direct access
                     to some of the object’s components, which means that the internal details of how an object
                     works are hidden from the outside world. This ensures that the object controls how its data is
                     accessed and modified, promoting data integrity.

                     Example: A TV remote controls the TV by sending signals when you press buttons. However,
                     you do not need to understand how these signals are generated or how the TV processes
                     them. The internal circuitry and the way the buttons are wired are hidden from you. You only
                     interact with the remote by pressing the buttons provided.
                     Abstraction: Abstraction is the process of simplifying complex reality by modelling classes
                     appropriate to the problem. It focuses on exposing only the essential features and behaviours
                     of an object while hiding the internal details. The goal is to reduce complexity and allow the
                     programmer to focus on interacting with the object rather than worrying about how it works
                     internally.
                     Example: When you drive a car, you interact with the steering wheel, pedals, and gear shift.
                     You don’t need to know how the fuel injection system works, how the engine converts fuel
                     into motion, or how the braking system operates. All those details are abstracted away so that
                     you can drive the car without understanding its internal mechanics.
                     Inheritance: Inheritance is a mechanism where a new class (called a subclass or derived class)
                     is created from an existing class (called a superclass or base class). The new class inherits all
                     the features (attributes and methods) of the base class and can also have additional features
                     of its own. This allows for code reuse and the creation of a hierarchy of classes.

                     Example: The Vehicle is a general category for all vehicles with common features like brand,
                     model,  speed,  and  essential  functions  (starting,  stopping,  accelerating).  Specific  types  of
                     vehicles—bikes, cars, buses, and trucks—inherit these basic features from Vehicle. Each type
                     then adds its own unique attributes, such as handlebars for bikes, doors and trunks for cars,
                     large seating for buses, and cargo areas for trucks.
                     Polymorphism: Polymorphism allows objects of different classes to be treated as objects of
                     a common superclass. In object-oriented programming, polymorphism allows objects to be
                     treated as instances of their parent class rather than their actual class. This means that a single
                     function or method can operate on different types of objects, making the code more flexible
                     and reusable.





                    50    TrackGPT iPRO (V5.0)-VIII
   47   48   49   50   51   52   53   54   55   56   57