{"id":2131,"date":"2020-02-11T04:47:59","date_gmt":"2020-02-11T04:47:59","guid":{"rendered":"https:\/\/studysection.com\/blog\/?p=2131"},"modified":"2020-02-11T04:47:59","modified_gmt":"2020-02-11T04:47:59","slug":"oops-concept-in-c","status":"publish","type":"post","link":"https:\/\/studysection.com\/blog\/oops-concept-in-c\/","title":{"rendered":"OOPs Concept in C#"},"content":{"rendered":"<h2>What is OOPs?<\/h2>\n<p><strong>Object-Oriented Programming<\/strong> is an approach where we focus on objects and data rather than actions and logic.<\/p>\n<h3>What are the main concepts of OOPs:<\/h3>\n<ul>\n<li>\n<strong>Class:<\/strong>&#8211; A class is the core of Object-Oriented Programming language. It consists of data and functions. It is mandatory to create class in OOPs.<br \/>\n<code><br \/>\nClass Employee<br \/>\n{<br \/>\n Public void addemployee()[Function for adding employee details]\n{<br \/>\nString name = \u201cabc\u201d;<br \/>\nInt empid = 101;<br \/>\n}<br \/>\n}<br \/>\n<\/code>\n<\/li>\n<li>\n<strong>Object:<\/strong>&#8211; Object is the run time entity of the class. We can access the class data of functions by creating an object of that class.<br \/>\n<code><br \/>\nEmployee objEmp = new Employee();<br \/>\n<\/code>\n<\/li>\n<p><\/p>\n<li>\n<strong>Abstraction:<\/strong>&#8211; Abstraction is the concept of hiding. It means we show the user <strong>What we do<\/strong> not <strong>How we do it<\/strong>. We can achieve abstraction by placing the abstract keyword in front of the class name.<br \/>\n<code><br \/>\nabstract class MobilePhone {<br \/>\n    public void Calling();<br \/>\n    public void SendSMS();<br \/>\n}<br \/>\n<\/code><br \/>\nFew of the properties of the abstract class are:<\/p>\n<ol>\n<li>Objects of the Abstract class can not be created.<\/li>\n<li>It can have both abstract and non-abstract methods<\/li>\n<li>It can have both constructors and static methods<\/li>\n<li>We must override all the abstract methods of the abstract class in the child class.<\/li>\n<\/ol>\n<\/li>\n<li><strong>Encapsulation:<\/strong><br \/>\nWrapping up the data and functioning together is known as Encapsulation.<br \/>\nWe can achieve encapsulation by declaring all the variables in the class as private and using properties to get and set those variables.\n<\/li>\n<li><strong>Polymorphism:<\/strong><br \/>\nPolymorphism means one name and many forms. It provides an ability to have multiple implementations with the same name in a class.<br \/>\nThere are 2 types of Polymorphism &#8211;<\/p>\n<ol>\n<li>Static \/ Compile Time Polymorphism<\/li>\n<li>Dynamic \/ Runtime Polymorphism<\/li>\n<\/ol>\n<p><img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2020\/02\/polymorphism.png\" alt=\"polymorphism\"\/><\/p>\n<\/li>\n<li><strong>Method Overloading<\/strong>:- In this concept, we create multiple functions with the same name and unique signatures and whenever we will call that function the compiler will decide which function to call based on the signature of the function.<br \/>\n<code><br \/>\nSyntax -<br \/>\npublic int Add(int a, int b, int c)<br \/>\n    {<br \/>\n      return a + b + c;<br \/>\n    }<br \/>\n    public int Add(int a, int b)<br \/>\n    {<br \/>\n      return a + b;<br \/>\n    }<br \/>\n<\/code>\n<\/li>\n<li><strong>Operator Overloading:<\/strong><br \/>\nIt gives the ability to use the same operator for various operations.<br \/>\n<code><br \/>\nSyntax  -<br \/>\naccess specifier  className  operator Operator_symbol (parameters)<br \/>\n{<br \/>\n  \/\/ Code<br \/>\n}<br \/>\n<\/code>\n<\/li>\n<li><strong>Method Overriding:<\/strong><br \/>\nIn method overriding we define the function with the same name and signature in the child class.<\/li>\n<li><strong>Inheritance:<\/strong><br \/>\nIt is a concept of reusing the already written code. We can inherit the code of the superclass and use it again in the child class.<\/p>\n<p><strong>Important terminology:<\/strong><\/p>\n<ul>\n<li>Super Class &#8211; A class whose features are inherited is called a superclass.<\/li>\n<li>Child Class &#8211; A class that is inheriting the superclass is known as child class.<\/li>\n<\/ul>\n<p><code><br \/>\nSyntax:<br \/>\nclass derived-class : base-class<br \/>\n{<br \/>\n  \/\/ methods and fields<br \/>\n}<br \/>\n<\/code><\/p>\n<h3><strong>Types of Inheritance:<\/strong><\/h3>\n<ol>\n<li>Single Inheritance &#8211; In this, a subclass inherits the features of a single superclass.<\/li>\n<li>Multilevel Inheritance &#8211; In Multilevel Inheritance, a derived class inherits the base class as well as the derived class. It also acts as the base class for other classes.<\/li>\n<li>Hierarchical Inheritance &#8211; In this type of Inheritance, one class serves as a superclass (base class) for more than one subclass.<\/li>\n<\/ol>\n<p><strong>Note: <\/strong>C# does not support multiple inheritances. We can achieve multiple inheritances with the help of the interface.\n<\/li>\n<li><strong>Interface:<\/strong> Interface is used to achieve the multiple inheritances which can not be achieved using the classes. The interface provides full abstraction because all of its methods are abstract and they can not have a body. All of the methods are public by default.\n<p>Few points about Interface &#8211; <\/p>\n<ul>\n<li>Its methods can not be private or protected, they are public by default.<\/li>\n<li>An interface can inherit one or more interfaces.<\/li>\n<li>A class that implements an interface must use a public access modifier.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><small><em>Being the most extensively used JavaScript library, a <a href=\"https:\/\/www.studysection.com\/jquery-3.x-advanced\">jQuery certification<\/a> will add enormous value to your skill-set. jQuery provides various functionalities to the developer in order to develop complex applications with ease and efficiency.<\/em><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is OOPs? Object-Oriented Programming is an approach where we focus on objects and data rather than actions and logic.<\/p>\n","protected":false},"author":1,"featured_media":2132,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[142,360],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>StudySection Blog - Object-Oriented Programming Concept in C#<\/title>\n<meta name=\"description\" content=\"Object-Oriented Programming is an approach where we focus on objects and data rather than actions and logic for web applications.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/studysection.com\/blog\/oops-concept-in-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"StudySection Blog - Object-Oriented Programming Concept in C#\" \/>\n<meta property=\"og:description\" content=\"Object-Oriented Programming is an approach where we focus on objects and data rather than actions and logic for web applications.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/studysection.com\/blog\/oops-concept-in-c\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog Posts on famous people, innovations and educational topics\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/studysection\" \/>\n<meta property=\"article:published_time\" content=\"2020-02-11T04:47:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2020\/02\/oops.png\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"admin-studysection-blog\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@studysection\" \/>\n<meta name=\"twitter:site\" content=\"@studysection\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin-studysection-blog\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/studysection.com\/blog\/oops-concept-in-c\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/oops-concept-in-c\/\"},\"author\":{\"name\":\"admin-studysection-blog\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\"},\"headline\":\"OOPs Concept in C#\",\"datePublished\":\"2020-02-11T04:47:59+00:00\",\"dateModified\":\"2020-02-11T04:47:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/studysection.com\/blog\/oops-concept-in-c\/\"},\"wordCount\":569,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"keywords\":[\"C\",\"OOPs\"],\"articleSection\":[\"Learn and Grow\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/studysection.com\/blog\/oops-concept-in-c\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/studysection.com\/blog\/oops-concept-in-c\/\",\"url\":\"https:\/\/studysection.com\/blog\/oops-concept-in-c\/\",\"name\":\"StudySection Blog - Object-Oriented Programming Concept in C#\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/#website\"},\"datePublished\":\"2020-02-11T04:47:59+00:00\",\"dateModified\":\"2020-02-11T04:47:59+00:00\",\"description\":\"Object-Oriented Programming is an approach where we focus on objects and data rather than actions and logic for web applications.\",\"breadcrumb\":{\"@id\":\"https:\/\/studysection.com\/blog\/oops-concept-in-c\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/studysection.com\/blog\/oops-concept-in-c\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/studysection.com\/blog\/oops-concept-in-c\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/studysection.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"OOPs Concept in C#\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/studysection.com\/blog\/#website\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"name\":\"Blog Posts on famous people, innovations and educational topics\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/studysection.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/studysection.com\/blog\/#organization\",\"name\":\"StudySection\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"contentUrl\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"width\":920,\"height\":440,\"caption\":\"StudySection\"},\"image\":{\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/studysection\",\"https:\/\/twitter.com\/studysection\",\"https:\/\/www.instagram.com\/study.section\/\",\"https:\/\/www.linkedin.com\/company\/studysection\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\",\"name\":\"admin-studysection-blog\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"caption\":\"admin-studysection-blog\"},\"url\":\"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"StudySection Blog - Object-Oriented Programming Concept in C#","description":"Object-Oriented Programming is an approach where we focus on objects and data rather than actions and logic for web applications.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/studysection.com\/blog\/oops-concept-in-c\/","og_locale":"en_US","og_type":"article","og_title":"StudySection Blog - Object-Oriented Programming Concept in C#","og_description":"Object-Oriented Programming is an approach where we focus on objects and data rather than actions and logic for web applications.","og_url":"https:\/\/studysection.com\/blog\/oops-concept-in-c\/","og_site_name":"Blog Posts on famous people, innovations and educational topics","article_publisher":"https:\/\/www.facebook.com\/studysection","article_published_time":"2020-02-11T04:47:59+00:00","og_image":[{"width":300,"height":200,"url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2020\/02\/oops.png","type":"image\/png"}],"author":"admin-studysection-blog","twitter_card":"summary_large_image","twitter_creator":"@studysection","twitter_site":"@studysection","twitter_misc":{"Written by":"admin-studysection-blog","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/studysection.com\/blog\/oops-concept-in-c\/#article","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/oops-concept-in-c\/"},"author":{"name":"admin-studysection-blog","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402"},"headline":"OOPs Concept in C#","datePublished":"2020-02-11T04:47:59+00:00","dateModified":"2020-02-11T04:47:59+00:00","mainEntityOfPage":{"@id":"https:\/\/studysection.com\/blog\/oops-concept-in-c\/"},"wordCount":569,"commentCount":0,"publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"keywords":["C","OOPs"],"articleSection":["Learn and Grow"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/studysection.com\/blog\/oops-concept-in-c\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/studysection.com\/blog\/oops-concept-in-c\/","url":"https:\/\/studysection.com\/blog\/oops-concept-in-c\/","name":"StudySection Blog - Object-Oriented Programming Concept in C#","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/#website"},"datePublished":"2020-02-11T04:47:59+00:00","dateModified":"2020-02-11T04:47:59+00:00","description":"Object-Oriented Programming is an approach where we focus on objects and data rather than actions and logic for web applications.","breadcrumb":{"@id":"https:\/\/studysection.com\/blog\/oops-concept-in-c\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/studysection.com\/blog\/oops-concept-in-c\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/studysection.com\/blog\/oops-concept-in-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/studysection.com\/blog\/"},{"@type":"ListItem","position":2,"name":"OOPs Concept in C#"}]},{"@type":"WebSite","@id":"https:\/\/studysection.com\/blog\/#website","url":"https:\/\/studysection.com\/blog\/","name":"Blog Posts on famous people, innovations and educational topics","description":"","publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/studysection.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/studysection.com\/blog\/#organization","name":"StudySection","url":"https:\/\/studysection.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","contentUrl":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","width":920,"height":440,"caption":"StudySection"},"image":{"@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/studysection","https:\/\/twitter.com\/studysection","https:\/\/www.instagram.com\/study.section\/","https:\/\/www.linkedin.com\/company\/studysection"]},{"@type":"Person","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402","name":"admin-studysection-blog","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","caption":"admin-studysection-blog"},"url":"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/"}]}},"views":286,"_links":{"self":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/2131"}],"collection":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/comments?post=2131"}],"version-history":[{"count":4,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/2131\/revisions"}],"predecessor-version":[{"id":2137,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/2131\/revisions\/2137"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media\/2132"}],"wp:attachment":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media?parent=2131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/categories?post=2131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/tags?post=2131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}