Skip to content

Desi banjara

learn and grow together

  • Azure
    • Azure Compute
      • Azure Logic Apps
      • Azure Mobile Apps
      • Azure App Service
      • Azure Serverless Computing
        • Azure Functions
    • Azure Networking services
      • Azure Networking – VNET
    • Azure Database Services
      • Azure SQL
      • Azure Data Factory
      • Azure Databricks
    • Azure Analytics Services
    • Azure Cognitive Services
    • Azure Data and Storage
    • Azure Devops
    • Azure landing zone
    • Azure IaaS
    • Azure Internet of Things (IoT)
      • Azure Machine Learning
      • Azure AI and ML services
    • Azure Migration
    • Microsoft Azure Log Analytics
  • Azure Security
    • Azure Identity and Access Management
    • Azure Active Directory
    • Azure Defender
    • Azure security tools for logging and monitoring
    • Azure Sentinel
    • Azure Sentinel – Data connectors
  • Agile Software development
    • Atlassian Jira
  • Amazon Web Services (AWS)
    • Amazon EC2
    • Amazon ECS
    • AWS Lambda
  • Google
    • Google Cloud Platform (GCP)
    • gmail api
    • Google Ads
    • Google AdSense
    • Google Analytics
    • Google Docs
    • Google Drive
    • Google Maps
    • Google search console
  • Software architecture
    • Service-oriented architecture (SOA)
    • Domain-Driven Design (DDD)
    • Microservices
    • Event-Driven Architecture
    • Command Query Responsibility Segregation (CQRS) Pattern
    • Layered Pattern
    • Model-View-Controller (MVC) Pattern
    • Hexagonal Architecture Pattern
    • Peer-to-Peer (P2P) pattern
    • Pipeline Pattern
  • Enterprise application architecture
  • IT/Software development
    • API development
    • ASP.Net MVC
    • ASP.NET Web API
    • C# development
    • RESTful APIs
  • Cybersecurity
    • Cross Site Scripting (XSS)
    • Reflected XSS
    • DOM-based XSS
    • Stored XSS attacks
    • Ransomware
    • cyber breaches
    • Static Application Security Testing (SAST)
  • Interview questions
    • Microsoft Azure Interview Questions
    • Amazon Web Services (AWS) Interview Questions
    • Agile Software development interview questions
    • C# interview questions with answers
    • Google analytics interview questions with answers
    • Javascript interview questions with answers
    • Python interview questions with answers
    • WordPress developer interview questions and answers
  • Cloud
    • Cloud computing
    • Infrastructure as a Service (IaaS)
    • Platform as a Service (PaaS)
    • Software as a Service (SaaS)
    • Zero Trust strategy
  • Toggle search form
  • SonarQube – Static code analysis SonarQube
  • Azure SQL Database Microsoft Azure
  • Azure Database for MySQL Azure
  • Azure Networking – Virtual Network (VNet) Azure
  • Azure Functions Azure Functions
  • Azure File Storage Azure File Storage
  • Microsoft AZ-104 Certification Exam Practice Questions – 2 Microsoft AZ-104 Certification Exam
  • How FinOps evaluates the cost efficiency of architectures in cloud? Cloud

Object Oriented Programming (OOP) in C#

Posted on September 9, 2018 By DesiBanjara No Comments on Object Oriented Programming (OOP) in C#

Interview Questions- Object Oriented Programming (OOP) in C#

 

1- What is Object oriented programming?

Object-oriented programming (OOP) is a programming model based on the concept of “objects”. Objects are the real world entities which can have data and some behaviour. Data we call as attributes or fields or properties. Behaviour we call as procedures or methods or functions. Objects use functions to perform operations on the data.

Example- A Mobile phone object can have attributes like brand, model, colour etc. The same object can have some behaviour functions like clickPhoto, saveImage, deleteImage etc.


2- What is a class in C#?

A class is a blueprint of an object that contains variables for storing data and functions to perform operations on the data. It is only a logical representation of data so it don’t occupy any memory space.

To create a class, you simply use the keyword “class” followed by the class name:

class MobilePhone  {

}


3- What is Object in C#?

An object is an instance of a class. It is like a bundle of variable and methods for a particular type of real world entities. It may represent a person, a place or any item. Example:

class Employee  {

string Name;

int Age;

string Email;

}

Creation of an Employee Object by using employee class

Employee Emp1 = new Employee ();

A class will not occupy any memory space. It is just a template to create objects. When an object is created using the new operator, memory is allocated for the class in the heap.


4- What is Abstraction?

In object oriented programming methodology, Abstraction means revealing only the essential characteristics of a thing without representing the background details. It is the process of hiding the working style of an object, and showing the information of an object in an understandable manner. It lets you focus on what the object does instead of how it does it.

Abstraction provides you a generalized view of your classes or objects by providing relevant information.

In C#, “Abstraction is accomplished using an Interface. Just giving the abstract information about what it can do without specifying the details.”


5- What is encapsulation?

Encapsulation is defined ‘as the process of enclosing one or more items within a physical or logical package’. In other words, Encapsulation is a process of binding data members (variables, properties) and member functions (methods) into a single unit. And Class is the best example of encapsulation.

In object oriented programming methodology, Encapsulation prevents access to implementation details. Through encapsulation a class can hide the internal details of how an object does something. A class can specify how accessible each of its members (variables, properties, and methods) is to code outside of the class or structure. Encapsulation simplifies the interaction between objects. An object can use another object without knowing all its data or how its data is maintained.

Example, an employee object might have name, address, and payroll properties. If a HR object wants to know the employee basic details (name and address), it can request the name and address for the employee without needing to know the payment details of the employee object.

A class uses access modifiers to accomplish the data hiding. These access modifiers are: public, private, protected, internal, and protected internal.


Explain various Access Modifiers in C#.

Access Modifiers describes accessibility of an Object and its members. We can control the accessibility of the member object of a class using access modifiers.

C# provide five access specifiers:

public: public can be access from anywhere that means there is no restriction on accessibility. The scope of the accessibility is inside class as well as outside. The type or member can be accessed by any other code in the same assembly or another assembly that references it.

private: The scope of the accessibility is limited only inside the classes or struct in which they are declared. The private members cannot be accessed outside the class and it is the least permissive access level.

protected: The scope of accessibility is limited within the class or struct and the class derived (Inherited) from this class. It means object of derived class can access the protected member of base class.

internal: The internal access modifiers can access within the program that contain its declarations and also access within the same assembly level but not from another assembly.

protected internal:

Protected internal is the mix access levels of both protected and internal. It can access anywhere in the same assembly and in the same class also the classes inherited from that class.



6- What is Inheritance in Object oriented programming?

Inheritance is one of the most important concepts in object-oriented programming. It is the ability to create a class that inherits attributes and behaviors from an existing class.

In other words, by using inheritance we can define parent class and child class. The child class inherits methods and properties of the parent class, but at the same time, they can also modify the behavior of the methods (method overriding) if required. Inheritance is a concept of code reusability.

7- What is Polymorphism in Object oriented programming?

Polymorphism is one of the fundamental concepts of object-oriented programming. Polymorphism is a Greek word that is created from two words: poly and morphos. The word poly means many and morphos means forms. In other words, “Many forms of a single object is called Polymorphism.”

Object oriented programming uses Polymorphism for using same operator or function with different types of operand and parameters. It means you can define same name method with different number and type of parameters.

There are two types of Polymorphism in C#

  • Static Polymorphism
  • Function overloading
  • Operator overloading
  • Dynamic Polymorphism

Dynamic Polymorphism can be achieved by using abstract classes and function overriding.

C# development, Interview questions, IT/Software development Tags:C#, C# development, Encapsulation, Inheritance, Interview questions, object oriented programming, object oriented programming methodology, OOP, Polymorphism

Post navigation

Previous Post: SOLID Design Principles
Next Post: ASP.Net MVC Interview Questions

Related Posts

  • Interview question: What is boxing and Unboxing in C#? C# development
  • Differences between struct and classes in C# : Interview question C# development
  • Interview question: What is the purpose of “as” operator in C#? C# development
  • Interview question: How to sort an array in C#? C# development
  • Interview questions – Microsoft Word Interview questions
  • Interview question: Which class acts as a base class for all arrays in C#? C# development

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Categories

  • Agile Software development
  • AI Writing & Automation
  • Amazon AWS Certification Exam
  • Amazon EC2
  • Amazon ECS
  • Amazon Web Services (AWS)
  • Apache Kafka
  • API development
  • API development
  • Apple Mac
  • Applications of Graph Theory
  • ARM templates
  • Artificial intelligence
  • ASP.NET Core
  • ASP.Net MVC
  • ASP.NET Web API
  • Atlassian Jira
  • Availability zones
  • AWS DevOps Engineer Professional Exam
  • AWS Lambda
  • AZ-300: Microsoft Azure Architect Technologies Exam
  • Azure
  • Azure Active Directory
  • Azure AD B2C
  • Azure AD Domain Services
  • Azure AI and ML services
  • Azure Analytics Services
  • Azure App Service
  • Azure Application Gateway
  • Azure Archive Storage
  • Azure Blob Storage
  • Azure Cache for Redis
  • Azure Cognitive Services
  • Azure Compute
  • Azure Container Instances (ACI)
  • Azure Core Services
  • Azure Cosmos DB
  • Azure Data and Storage
  • Azure Data Factory
  • Azure Data Lake Storage
  • Azure Database for MySQL
  • Azure Database for PostgreSQL
  • Azure Database Migration Service
  • Azure Database Services
  • Azure Databricks
  • Azure DDoS Protection
  • Azure Defender
  • Azure Devops
  • Azure Disk Storage
  • Azure ExpressRoute
  • Azure File Storage
  • Azure Firewall
  • Azure Functions
  • Azure HDInsight
  • Azure IaaS
  • Azure Identity and Access Management
  • Azure instance metadata service
  • Azure Internet of Things (IoT)
  • Azure Key Vault
  • Azure Kubernetes Service (AKS)
  • Azure landing zone
  • Azure Lighthouse
  • Azure Load Balancer
  • Azure Logic Apps
  • Azure Machine Learning
  • Azure Machine Learning
  • Azure Migration
  • Azure Mobile Apps
  • Azure Network Watcher
  • Azure Networking – VNET
  • Azure Networking services
  • Azure Pricing and Support
  • Azure Pricing Calculator
  • Azure Queue Storage
  • Azure regions
  • Azure Resource Manager
  • Azure Security
  • Azure Security Center
  • Azure Security Information and Event Management (SIEM)
  • Azure security tools for logging and monitoring
  • Azure Security, Privacy, Compliance, and Trust
  • Azure Sentinel
  • Azure Sentinel – Data connectors
  • Azure Serverless Computing
  • Azure Service Level Agreement (SLA)
  • Azure SLA calculation
  • Azure SQL
  • Azure SQL Database
  • Azure Storage
  • Azure Stream Analytics
  • Azure Synapse Analytics
  • Azure Table Storage
  • Azure Virtual Machine
  • Azure VNET
  • Azure VPN Gateway
  • Blogging
  • Business
  • C# development
  • C# interview questions with answers
  • Career success
  • CDA (Clinical Document Architecture)
  • ChatGPT
  • CI/CD pipeline
  • CISSP certification
  • CKEditor
  • Cloud
  • Cloud computing
  • Cloud Computing Concepts
  • Cloud FinOps
  • Cloud FinOps Optmisation
  • Cloud services
  • COBIT
  • Command Query Responsibility Segregation (CQRS) Pattern
  • Configure SSL offloading
  • Content Creation
  • Content management system
  • Continuous Integration
  • conversational AI
  • Cross Site Scripting (XSS)
  • cyber breaches
  • Cybersecurity
  • Data Analysis
  • Data Clean Rooms
  • Data Engineering
  • Data Warehouse
  • Database
  • DeepSeek AI
  • DevOps
  • DevSecOps
  • Docker
  • DOM-based XSS
  • Domain-Driven Design (DDD)
  • Dynamic Application Security Testing (DAST)
  • Enterprise application architecture
  • Event-Driven Architecture
  • GIT
  • git
  • gmail api
  • Google
  • Google Ads
  • Google AdSense
  • Google Analytics
  • Google analytics interview questions with answers
  • Google Cloud Platform (GCP)
  • Google Docs
  • Google Drive
  • Google Flights API
  • Google Maps
  • Google search console
  • Graph Algorithms
  • Graph theory
  • Healthcare Interoperability Resources
  • Hexagonal Architecture Pattern
  • HL7 vs FHIR
  • HTML
  • IBM qradar
  • Information security
  • Infrastructure as a Service (IaaS)
  • Internet of Things (IoT)
  • Interview questions
  • Introduction to DICOM
  • Introduction to FHIR
  • Introduction to Graph Theory
  • Introduction to HL7
  • IT governance
  • IT Infrastructure networking
  • IT/Software development
  • Javascript interview questions with answers
  • Kubernetes
  • Layered Pattern
  • Leadership
  • Leadership Quote
  • Life lessons
  • Load Balancing Algorithms
  • Low-code development platform
  • Management
  • Microservices
  • Microservices
  • Microsoft
  • Microsoft 365 Defender
  • Microsoft AI-900 Certification Exam
  • Microsoft AZ-104 Certification Exam
  • Microsoft AZ-204 Certification Exam
  • Microsoft AZ-900 Certification Exam
  • Microsoft Azure
  • Microsoft Azure certifications
  • Microsoft Azure Log Analytics
  • Microsoft Cloud Adoption Framework
  • Microsoft Exam AZ-220
  • Microsoft Exam AZ-400
  • Microsoft Excel
  • Microsoft Office
  • Microsoft Teams
  • Microsoft Teams
  • Microsoft word
  • Model-View-Controller (MVC) Pattern
  • Monitoring and analytics
  • NoSQL
  • OpenAI
  • OutSystems
  • Peer-to-Peer (P2P) pattern
  • Personal Growth
  • Pipeline Pattern
  • PL-100: Microsoft Power Platform App Maker
  • PL-200: Microsoft Power Platform Functional Consultant Certification
  • PL-900: Microsoft Power Platform Fundamentals
  • Platform as a Service (PaaS)
  • Postman
  • Project management
  • Python interview questions with answers
  • Rally software
  • Ransomware
  • Reflected XSS
  • RESTful APIs
  • Rich Text Editor
  • SC-100: Microsoft Cybersecurity Architect
  • Scrum Master Certification
  • Service-oriented architecture (SOA)
  • SIEM
  • Software architecture
  • Software as a Service (SaaS)
  • SonarQube
  • Splunk
  • SQL
  • SQL Azure Table
  • SQL Server
  • Startup
  • Static Application Security Testing (SAST)
  • Stored XSS attacks
  • System Design Interview
  • Table Storage
  • Test Driven Development (TDD)
  • TinyMCE
  • Top technology trends for 2023
  • Types of Graphs
  • Uncategorized
  • User Experience (UX) design
  • Version control system
  • virtual machine scale set
  • visual studio
  • WCF (Windows Communication Foundation)
  • Web development
  • Windows Hello
  • WordPress
  • WordPress developer interview questions and answers
  • Yammer
  • Zero Trust strategy



Recent Posts

  • Ace Your FAANG System Design Interview like Google & Amazon: The 8 Whitepapers You Must Read
  • From $0 to $10K/Month Writing Online – The Exact Roadmap to Build a Profitable Writing Career
  • How to Write an AI-Generated Article That Feels 100% Human Using ChatGPT
  • DeepSeek AI: The OpenAI Rival You Didn’t See Coming (But Should)
  • 10 Ways AI is Revolutionizing Healthcare (And Why Your Doctor Might Just Be a Robot Soon)
  • DOM-based XSS Cybersecurity
  • Azure Queue Storage Azure Queue Storage
  • What is OpenAI? OpenAI
  • Microsoft AZ-900 Certification Exam Practice Questions – Part 1 Microsoft AZ-900 Certification Exam
  • Famous Buddha Quotes on Life Life lessons
  • WordPress – How to switch to Block Editor Content management system
  • CKEditor CKEditor
  • Python interview questions with answers Python interview questions with answers

Copyright © 2025 Desi banjara.

Powered by PressBook News WordPress theme