Skip to content

palak-in/Object-Oriented-Programming-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Object-Oriented-Programming-

Introduction to Programming Approaches

  • Object-oriented programming (OOP) views a problem as a collection of objects that interact, much like real-world entities such as cars, persons, or bank accounts. Each object represents an entity with specific properties and behaviors. For example, a car is an object with properties (color, model) and behaviors (start, stop).

Basic Data Types and Derived Data Types

Basic Data Types: Describe simple values like int, float, char, double.

  • Real-life: Age (int), price (float), grade (char).

  • Derived Data Types: Created from basic types, e.g., arrays, pointers, structures.

Example: Student list (array), address (structure).

Keywords, Identifiers, Constants, and Variables

  • Keywords: Reserved words (e.g., int, class, if) used for language syntax.

  • Identifiers: User-defined names for entities (variables, functions, classes). Example: personName, carColor.

  • Constants: Fixed values, such as π in math.

  • Variables: Containers for changing data, like balance in a bank account.

Type Casting, Operators, and Operator Precedence

  • Type Casting: Converting one data type to another (e.g., int to float). Example: Rounding rupees to whole numbers.

  • Operators: Used for operations (arithmetic, logical, relational).

Example: salary + bonus.

  • Operator Precedence: Rules that determine order of operations (multiplication before addition).

Control Structures

  • if Statement: Decides based on a condition. Example: If temperature > 30°C, turn on AC.

  • switch-case: Selects among multiple choices. Example: Menu selection in a restaurant.

  • for, while, do-while loops: Repeat tasks. For example, for loop counting days in a month; while loop checking machine status; do-while ensuring a task runs at least once.

  • break and continue: Control loop execution (break exits, continue skips to next iteration).

Features of Object-Oriented Programming

  • Class A class is a blueprint/template for objects. Real-life example: The concept “Car” is a class; actual cars (Honda, BMW) are objects.

  • Object Objects are instances of classes, representing unique things. For example, a bank account object has its own account number and balance.

  • Encapsulation Wrapping data and methods together, protecting the data. Banking system uses encapsulation: account details are hidden; only authorized operations can access them.

  • Abstraction Showing only essential features, hiding complexity. For instance, when driving a car, only gears and speed are visible, not internal engine details.

  • Data Hiding Similar to encapsulation, keeps data safe from outside interference. For example, passwords are hidden in a web application.

  • Polymorphism One function or operator performs multiple roles. For example, a remote's “power” button can turn on a TV, fan, or AC based on context.

  • Inheritance Objects acquire properties from other objects. For example, a “SportsCar” class inherits features of the “Car” class but adds its own unique features.

About

Cover Introduction

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published