Oops Concepts


        
   

Oops


Key Words




OOPS  Key words & Definitions


In Object-Oriented Programming (OOP), various keywords and concepts define how objects and classes interact.


Below is a comprehensive list:



1. Class

A class is like a blueprint for creating objects.
📌 Example: A Car class can define attributes like color, brand, speed and methods like start() and stop().


2. Object

An object is an instance of a class.
📌 Example: A BMW Car object is created from the Car class and has specific properties like black color and 220 km/h max speed.


3. Encapsulation

Encapsulation hides the internal details of an object and only exposes necessary parts.
📌 Example: A bank account class hides the balance variable, allowing access only through deposit() and withdraw() methods.



4. Inheritance

A child class can inherit properties from a parent class.
📌 Example: A Bird class has a function called fly(). A Parrot class inherits from it and can also fly without redefining the function.


5. Polymorphism

The same function behaves differently in different scenarios.
📌 Example: A makeSound() function produces "Meow" for a Cat and "Bark" for a Dog.


6. Abstraction

Abstraction hides unnecessary details and only exposes essential features.
📌 Example: When you press the brake pedal, the car stops. You don’t need to know how the brake mechanism works internally.


7. Interface

An interface defines a contract that must be followed.
📌 Example: A TV Remote has buttons for volume and power. No matter the brand, every TV follows the same remote interface.


8. Constructor

A constructor initializes an object when it is created.
📌 Example: When you buy a smartphone, it comes with default settings like brightness, volume, and wallpaper.




9. Destructor

A destructor is used to free memory when an object is destroyed.
📌 Example: When you close a game, it releases RAM used by the game so that the system can use it for other tasks.


10. Static

A static variable or method belongs to the class itself, not any specific object.
📌 Example: A company’s tax rate is the same for all employees, so it is declared static.


11. This Keyword

The this keyword refers to the current instance of the object.
📌 Example: If Praveen is an object in a Person class, the this keyword ensures that his name is correctly assigned.


12. Super Keyword

The super keyword calls the parent class’s methods or constructors.
📌 Example: A Manager class inherits from an Employee class. Using super, the Manager can call the Employee's salary calculation method.


13. Final Keyword

The final keyword prevents modification of a variable, method, or class.
📌 Example: The value of Pi (3.1416) in a Math class is set as final so it can’t be changed.



14. Abstract Class

An abstract class can’t be instantiated but can be inherited.
📌 Example: A Vehicle class defines a move() function but doesn’t specify how. A Car class and a Bike class implement move() in their own way.


15. Pointer (C++ Specific)

A pointer stores the memory address of an object or variable.
📌 Example: A Google Maps app stores your current location (pointer) and updates it in real-time.


16. Union (C & C++ Specific)

A union allows different data types to share the same memory location.
📌 Example: A smartphone has a single memory chip that stores contacts, messages, and apps, but at different times.


17. Float Data Type

A float is used to store decimal values.
📌 Example: The temperature in a weather app is stored as a float (e.g., 27.5°C).


18. Multiple Inheritance (C++ Specific)

A class can inherit from multiple parent classes.
📌 Example: A Smartphone inherits from both Camera (to take pictures) and Phone (to make calls).




19. Virtual Function (C++ Specific)

A virtual function allows function overriding in derived classes.
📌 Example: A Gaming Console has a play() function. A PS5 and Xbox redefine the play() function differently.


20. Interface vs. Abstract Class

  • Interface → Only method declarations, no implementation.

  • Abstract Class → Can have both defined and undefined methods.

📌 Example:

  • A USB Port is an interface → Every device must follow its standard.

  • A Car is an abstract class → Some features are implemented.


21. Assign

Assigning means giving a value to a variable.
📌 Example: When filling out a form, you assign your name to the "Name" field.


22. Define

Defining means creating something with a specific structure like a function or variable.
📌 Example: Defining a recipe for making a cake – you provide ingredients and instructions.


23. Declare

Declaring means introducing a variable or function without assigning a value.
📌 Example: You declare a meeting time before finalizing the exact schedule.

24. Variable

A variable is a named storage location that holds data.
📌 Example: A shopping cart stores the total price, which changes when you add or remove items.


25. Protocol

A protocol is a set of rules for communication.
📌 Example: In WhatsApp messaging, both sender and receiver follow a protocol to send and receive messages correctly.


26. Syntax

Syntax is the set of rules that define how code should be written.
📌 Example: A grammar book defines the correct way to write sentences in English.

27. Operators

Operators perform mathematical or logical operations on values.
📌 Example: A calculator uses operators like + (addition), - (subtraction), * (multiplication), and / (division).


28. Operands

Operands are the values used with operators.
📌 Example: In 5 + 3, the numbers 5 and 3 are operands, and + is the operator.


29. Functions

A function is a reusable block of code that performs a task.
📌 Example: A coffee machine has functions like makeEspresso(), makeCappuccino(), and addMilk().

30. Constants

A constant is a fixed value that doesn’t change.
📌 Example: The value of π (3.1416) remains the same in mathematics.


31. Header

A header file contains declarations and functions used in a program.
📌 Example: A table of contents in a book lists all sections before reading.


32. Global & Local Variables

  • Global Variable: Accessible anywhere in the program.

  • Local Variable: Only accessible within a specific function.
    📌 Example:

  • A company’s CEO (Global) can access everything.

  • A team manager (Local) can only manage his own team.


33. Conditions

Conditions control what happens based on a decision.
📌 Example: If it rains, you carry an umbrella; otherwise, you don't.


34. Parenthesis ()

Parentheses group expressions and control the order of operations.
📌 Example: In a mathematical equation (2 + 3) × 4, the parentheses ensure that 2 + 3 is calculated first.


35. Arguments

Arguments are values passed into functions to perform a task.
📌 Example: A pizza order function can take arguments like size, toppings, and crust type.

36. Objects

Objects are instances of a class, containing data (attributes) and actions (methods).
📌 Example: A smartphone object has attributes like brand, model, and battery life and methods like makeCall() and takePhoto().


37. Structures

A structure is a collection of variables of different data types grouped together.
📌 Example: A student record has different fields like Name (String), Age (Integer), and Marks (Float).


38. Array

An array is a collection of values stored in a single variable.
📌 Example: A playlist stores multiple songs in one list.


     39. List

A list is similar to an array but can store different data types and is more flexible.
📌 Example: A to-do list contains tasks like "Buy groceries" (String) and "2 hours workout" (Integer).


40. Integer

An integer is a whole number (without decimals).
📌 Example: The number of students in a class (e.g., 50) is stored as an integer.



41. Float

A float is a number with a decimal point.
📌 Example: A temperature reading (e.g., 36.5°C) is stored as a float.


42. Data Type

A data type defines the kind of value a variable can hold (integer, float, string, etc.).
📌 Example: A passport form has fields with different data types like Name (String), Age (Integer), and Height (Float).


43. Union

A union allows different variables to share the same memory location.
📌 Example: A digital clock displays either hours-minutes-seconds or date-month-year, but only one at a time.


44. Enumeration (enum)

An enum is a set of named constants.
📌 Example: The days of the week (Monday, Tuesday, etc.) can be stored as an enum.


45. Inline Function

An inline function is a function that is expanded at the point of call, rather than being executed separately.
📌 Example: A shortcut key (Ctrl + C) directly executes the copy function instead of calling a separate menu.










Popular posts from this blog

Road for developers