<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>object-oriented-programming on Siddharth Arumugam - Blog</title><link>https://mrnight-blog.netlify.app/tags/object-oriented-programming/</link><description>Recent content in object-oriented-programming on Siddharth Arumugam - Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Sun, 07 Aug 2022 17:00:00 +0530</lastBuildDate><atom:link href="https://mrnight-blog.netlify.app/tags/object-oriented-programming/index.xml" rel="self" type="application/rss+xml"/><item><title>Object Oriented Programming (OOP)</title><link>https://mrnight-blog.netlify.app/posts/object-oriented-programming/</link><pubDate>Sun, 07 Aug 2022 17:00:00 +0530</pubDate><guid>https://mrnight-blog.netlify.app/posts/object-oriented-programming/</guid><description>What is object oriented programming? Object-oriented programming (OOP) is a programming paradigm (style of programming) based on objects.
Some programming languages based on OOP are Java, C++, JavaScript, Python, etc.
OOP Terms Let us first learn some of the key terms used in OOP.
Method Member function of a class. Each method contains a method signature which comprises of the method name and method parameter types.
State Member variable of a class, accessible by its methods.</description><content>&lt;h2 id="what-is-object-oriented-programming">What is object oriented programming?&lt;/h2>
&lt;p>Object-oriented programming (OOP) is a programming paradigm (style of programming) based on &lt;a href="#object">objects&lt;/a>.&lt;/p>
&lt;p>Some programming languages based on OOP are Java, C++, JavaScript, Python, etc.&lt;/p>
&lt;h2 id="oop-terms">OOP Terms&lt;/h2>
&lt;p>Let us first learn some of the key terms used in OOP.&lt;/p>
&lt;h4 id="method">Method&lt;/h4>
&lt;p>Member function of a class. Each method contains a method signature which comprises of the method name and method parameter types.&lt;/p>
&lt;h4 id="state">State&lt;/h4>
&lt;p>Member variable of a class, accessible by its methods.&lt;/p>
&lt;h4 id="class">Class&lt;/h4>
&lt;p>A class is a user-defined data type that is a template for an object.
The class provides the initial values for state and contains methods.&lt;/p>
&lt;h4 id="object">Object&lt;/h4>
&lt;p>An object is an instance of a class. It is a combination of variables and methods.&lt;/p>
&lt;h2 id="basic-principles-of-oop">Basic principles of OOP&lt;/h2>
&lt;p>Object-oriented programming encompasses four basic principles: &lt;a href="#data-abstraction">Data Abstraction&lt;/a>, &lt;a href="#inheritance">Inheritance&lt;/a>, &lt;a href="#encapsulation">Encapsulation&lt;/a>, &lt;a href="#polymorphism">Polymorphism&lt;/a>.&lt;/p>
&lt;h4 id="data-abstraction">Data Abstraction&lt;/h4>
&lt;p>Data abstraction refers to showing only essential information to the user, while hiding the underlying implementation details.&lt;/p>
&lt;p>For example, we are able to dial a phone number and make a call. However, we don&amp;rsquo;t know the internal working of the phone and how the signals are transmitted.&lt;/p>
&lt;h4 id="inheritance">Inheritance&lt;/h4>
&lt;p>Inheritance is the process by which a class (subclass) acquires the properties of another class (superclass). The subclass gets all the features of the base class and can have its own.&lt;/p>
&lt;blockquote>
&lt;p>The &lt;em>subclass&lt;/em> is also called the &lt;em>derived/extended/child&lt;/em> class.&lt;br>
The &lt;em>superclass&lt;/em> is also called the &lt;em>base/parent&lt;/em> class.&lt;/p>
&lt;/blockquote>
&lt;h4 id="encapsulation">Encapsulation&lt;/h4>
&lt;p>Encapsulation implements data hiding by restricting direct access to internal object details (such as variables, methods) from outside.&lt;/p>
&lt;p>Data within the class are accessible by functions inside the class, but not by outside functions.&lt;/p>
&lt;p>For example, in a banking application, access to confidential data such as account numbers, credentials are restricted from outside.&lt;/p>
&lt;h4 id="polymorphism">Polymorphism&lt;/h4>
&lt;p>The term polymorphism comes from the Greek roots &lt;em>poly&lt;/em> (many) and &lt;em>morph&lt;/em> (form).&lt;/p>
&lt;p>Polymorphism is the ability of an object to have many forms.&lt;/p>
&lt;p>&lt;strong>Types of polymorphism&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>Compile-time/static polymorphism&lt;/p>
&lt;p>Compile-time polymorphism is resolved during the compilation process.
It is implemented through &lt;strong>method overloading&lt;/strong>.&lt;/p>
&lt;p>Method overloading refers to creating multiple methods with the same name but different parameters in the same class.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Runtime/dynamic polymorphism&lt;/p>
&lt;p>Runtime polymorphism is resolved at runtime.
It is implemented through &lt;strong>method overriding&lt;/strong>.&lt;/p>
&lt;p>Method overriding allows a subclass to have a different implementation of a method already declared in the superclass.&lt;/p>
&lt;/li>
&lt;/ul></content></item></channel></rss>