SlideShare une entreprise Scribd logo
1  sur  26
OOP Most asked interview
questions
On this slideshare we will be sharing Q &
A which will dig through some quick
basics on programming - OOP based
interview question and answers.
1. What is OOP?
 OOP Stands for Object Oriented Programming.
It deals with organizing a programming language model
around an object rather dealing with Actions and data
rather than logic.
Instead of procedural programming which is based on a
list of actions OOP is created to be modelled around
objects that interact with one another.
2. What is an Object in OOP?
 Every Entity is considered as an object for which its
characteristics can be described by using features of OOP
concepts.
An Object can be defined as an Instance of a Class and
are basic run time entities.
3. What is a Class?
 A Class is at the core of Object Oriented
Programming
A Class can be said to be a Blueprint of an
object that contains functions to perform
action and variable to store data.
A class contains behaviour and Data in Entity.
A class can inherit behaviour and data
members from other classes.
4. Explain Encapsulation in OOP?
 Data Encapsulation is the Concept of hiding all the
implementation details of a class from the End-user by
binding data and code into a single unit.
In Encapsulation we define fields as Private as opposed
to declaring it as Public.
5. What is Polymorphism?
 The word Polymorphism translates to having many
forms.Polymorphism can be expressed as ‘One
Interface, Multiple functions’ Polymorphism lets us
invoke methods of derived class through base class
reference during runtime.
6. Explain Constructors?
 A Constructor is a Special Method of a Class in a
program which gets invoked when the instance of a
class is created.
A Constructor must have the same name as the class
and it gets initialized whenever
The class gets initialized whenever we access that class.
A Constructor does not have a return type.
It can also be overloaded and it can be used to initialize
variables.
There are two types of Constructors:
Implicit and Explicit Constructors where implicit
constructors are internally created in .Net Framework
while we can declare explicit constructors as we wish.
7. Explain Destructors?
 A Destructor cannot be manually invoked in C#
It is automatically invoked when an object is to be
destroyed.
Name of the Destructor is the same as the Class
along with being prefixed with a tilde (~).
Destructor is used to clear dynamically allocated
memory and free the resources to allocate to
other process.
Destructors do not have a return type in C#.
Destructors are public by default and cannot be
overloaded.
8. Explain Abstraction in OOP?
 Abstraction is the Process of only displaying
relevant information without displaying the
background details.
Abstract Class: Incomplete class /Partial Class
Abstract Method: Incomplete function An
Abstract class can contain Abstract as well as
non-abstract methods. Abstract class must
always be public and must be declared with
the abstract keyword.
An Abstract class cannot be directly
instantiated.
9. What is Interface?
An Interface can be defined as a Template and it
can contain only the Signature of the class in C#.
An Interface cannot contain any implementation.
Multiple interface inheritance along with a single
base class is possible.
When an Interface is declared public then its
function do not need to be declared with a public
keyword.
Base class must always be inherited prior to
interface.
10. What is function overloading?
Function Overloading or Method Overloading
allows us to have two methods with same name
but different signature.
Overloading occurs at Compile time and can be
called as compile time polymorphism.
Method overloading can be used in the same
class or a child class in C#.
Method overloading can be used in C# by doing
the following:
Changing the number of parameters in the
method, changing the order of the parameters in
the method and using datatypes which are
different from each other.
11. What is Method Overriding?
Method Overriding allows us to have two
methods with same name and same Signature.
Method Overriding occurs at Compile time and
can be called as compile time polymorphism.
Method overriding is only possible in child class
not inside the same class from where the method
is declared.
Method overriding can be done in C# by creating
a method in a derived class with same
parameters, same name and same return type as
in base class.
12. What are Access Modifiers?
An access specifier defines the visibility and
scope of a class member in C#.
C# has Four Access Modifiers:
• Protected
• Internal
• Public
•Private
13. What are the various types of
Constructors?
 There are Five types of Constructors in C#:
• Default Constructor
• Parameterized Constructor
• Copy Constructor
• Static Constructor
•Private Constructor
14. Explain Exception Handling?
In C# Exception handling features help us deal
with any unexpected or exceptional situations
which occur when a program is in run time.
Exception handling in C# uses the try
(Keyword), catch (Keyword), and finally
(Keyword) keywords to try actions which may
not succeed and to handle failures when you
decide that it is necessary to do so final
keyword executes regardless if an error occurs
or not.
15. Explain the Difference between Abstraction
and Encapsulation?
Encapsulation involves wrapping and hiding
properties and methods. To protect the data
from the end user we use encapsulates which
hides the code and data into a single unit.
In C# class can be used as the best example of
encapsulation. In Abstraction we only show
the necessary details to the intended user.
16. Explain Delegates?
 C# act in a similar way as to that of C and C++
Pointers. A delegate is a reference type
variable that contains the reference to a
function and the reference can be changed at
runtime.
Delegates are usually used for call-back
methods and implementing events.
In C# all delegates are implicitly derived from
the inbuilt System.Delegate class.
17. What are Events?
 Events are Special members of the class that
invokes them. When an Action occurs a class
can raise an event, which have a message that
contain information’s about the event (event
arguments) and send them out to the rest of
the application, other parts of the application
can respond to the event by executing
methods called event handlers.
Event handler is a method in C# that has the
same signature as the event and this method is
executed when the event occurs.
18. What are Nested Classes?
Nested Class is creating a class in another class
in C#. Nested Classes are instantiated
separately to its parent class and are not
instantiated automatically by its parent.
If a nested class is declared private it can only
be accessed by its parent class or other nested
class along with it.
19. Explain Generics in OOP?
Generics in C# allows us to specify the
datatypes of a program which maybe used
inside a class or a method when the variable is
used in the program. Hence Generics allows
us write a Class or Method that can work with
any datatype in C#.
It allows us to implement core OOP features
such as Code reuse, Type Safety and
performance.
20. Explain Inheritance?
Inheritance is one of the most important
concept of OOP in C#.
The main purpose of Inheritance is Code
Reusability and avoiding Code Duplication.
Instead of creating new Data Members and
Member Function for new class which already
exist we can just inherit it from existing class
that already contains those members.
21. What is the default access specifier in a class
definition?
Private is the default access specifier in class
definition in C#.
22. What are the Types of Inheritance?
The different types of Inheritance in C# are as
follows:
• Single Inheritance: can only be inherited into one
child class.
• Hierarchical Inheritance: base class can be
inherited into multiple child classes
• Multilevel Inheritance: Contains a class derived
from a another child class.
Multiple inheritance is not supported in C#.
23. What are Sealed Classes?
Inheritance can be disabled by using the
sealed keyword on a class or a method.
We cannot derive other classes from it when
use on a base class.
Derived classes can’t override the method
when used on a Method.
24. Explain Static Classes and Members?
A Static class is the same as a non-static class
apart from the difference that a static class
cannot be instantiated or we use a new
keyword to create a variable of class type.
We can access the members of the static class
by using the class name.
Static members can be called even when no
instance of a class has been created in C#
Static members and properties cannot access
the non-static events and fields in their
containing type.
25. What is Virtual Methods?
Virtual methods are methods which are
compulsorily declared with the virtual keyword.
The virtual keyword signifies that this method can
be overridden by a child class using the override
keyword.
26. What are the Types of the Polymorphism?
 There two types of polymorphism :
• Static Polymorphism: Object is linked with
Method in Compile time.
• Dynamic Polymorphism: Object is linked to
Method in Runtime.
27. What are the Advantages of OOP?
 Advantages of OOP programming are Code
Reusability via Inheritance, Data Security via
encapsulation, Simple User interface via Abstraction
and structured class approach with Objects which
allows to maintain code with easy detection of
errors.
28. Explain Difference between an Abstract class
and Interface?
In C# a Class can extend only one abstract
class while it can implement several
interfaces.
Interface can only have public members while
abstract class can be private and protected.
Interface can extend another Interface only
while any class can extend an abstract class
Interfaces cannot contain body of any of its
method or data members as opposed to an
abstract class which can implement methods.
29. Explain Multicast Delegate?
 A Multicast delegate is a variable which has
reference to more than one function.
All the functions to which the multicast
delegate point to are invoked when the
Multicast delegate is invoked.
There are two ways to create multicast
delegate are as follows:
• + or += to Subscribe a method with the
delegate
• - or -= to Unsubscribe a method with the
delegate

Contenu connexe

Tendances (20)

Characteristics of OOPS
Characteristics of OOPS Characteristics of OOPS
Characteristics of OOPS
 
Delegates and events in C#
Delegates and events in C#Delegates and events in C#
Delegates and events in C#
 
Class Diagram
Class DiagramClass Diagram
Class Diagram
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Polymorphism in Python
Polymorphism in Python Polymorphism in Python
Polymorphism in Python
 
Oops in Java
Oops in JavaOops in Java
Oops in Java
 
Constructors in java
Constructors in javaConstructors in java
Constructors in java
 
OOP java
OOP javaOOP java
OOP java
 
software engineer interview questions.pdf
software engineer interview questions.pdfsoftware engineer interview questions.pdf
software engineer interview questions.pdf
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS Concept
 
Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
 
Oop java
Oop javaOop java
Oop java
 
Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
class and objects
class and objectsclass and objects
class and objects
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
Inheritance in OOPs with java
Inheritance in OOPs with javaInheritance in OOPs with java
Inheritance in OOPs with java
 
Inheritance C#
Inheritance C#Inheritance C#
Inheritance C#
 
Object oriented programming in python
Object oriented programming in pythonObject oriented programming in python
Object oriented programming in python
 

Similaire à OOP interview questions & answers.

EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerJeba Moses
 
Data Structure Interview Questions & Answers
Data Structure Interview Questions & AnswersData Structure Interview Questions & Answers
Data Structure Interview Questions & AnswersSatyam Jaiswal
 
C#.net interview questions for dynamics 365 ce crm developers
C#.net interview questions for dynamics 365 ce crm developersC#.net interview questions for dynamics 365 ce crm developers
C#.net interview questions for dynamics 365 ce crm developersSanjaya Prakash Pradhan
 
OOP in Java Presentation.pptx
OOP in Java Presentation.pptxOOP in Java Presentation.pptx
OOP in Java Presentation.pptxmrxyz19
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPTAjay Chimmani
 
Top 20 c# interview Question and answers
Top 20 c# interview Question and answersTop 20 c# interview Question and answers
Top 20 c# interview Question and answersw3asp dotnet
 
Android interview questions
Android interview questionsAndroid interview questions
Android interview questionssatish reddy
 
Android interview questions
Android interview questionsAndroid interview questions
Android interview questionssatish reddy
 
OOP in Python, a beginners guide..........
OOP in Python, a beginners guide..........OOP in Python, a beginners guide..........
OOP in Python, a beginners guide..........FerryKemperman
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonSujith Kumar
 

Similaire à OOP interview questions & answers. (20)

EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answer
 
Intervies
InterviesIntervies
Intervies
 
Data Structure Interview Questions & Answers
Data Structure Interview Questions & AnswersData Structure Interview Questions & Answers
Data Structure Interview Questions & Answers
 
C++ interview question
C++ interview questionC++ interview question
C++ interview question
 
C#.net interview questions for dynamics 365 ce crm developers
C#.net interview questions for dynamics 365 ce crm developersC#.net interview questions for dynamics 365 ce crm developers
C#.net interview questions for dynamics 365 ce crm developers
 
OOP in Java Presentation.pptx
OOP in Java Presentation.pptxOOP in Java Presentation.pptx
OOP in Java Presentation.pptx
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
 
C# interview
C# interviewC# interview
C# interview
 
Php oop (1)
Php oop (1)Php oop (1)
Php oop (1)
 
C# interview
C# interviewC# interview
C# interview
 
Unusual C# - OOP
Unusual C# - OOPUnusual C# - OOP
Unusual C# - OOP
 
Top 20 c# interview Question and answers
Top 20 c# interview Question and answersTop 20 c# interview Question and answers
Top 20 c# interview Question and answers
 
C#
C#C#
C#
 
C# interview questions
C# interview questionsC# interview questions
C# interview questions
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Core java questions
Core java questionsCore java questions
Core java questions
 
Android interview questions
Android interview questionsAndroid interview questions
Android interview questions
 
Android interview questions
Android interview questionsAndroid interview questions
Android interview questions
 
OOP in Python, a beginners guide..........
OOP in Python, a beginners guide..........OOP in Python, a beginners guide..........
OOP in Python, a beginners guide..........
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 

Plus de Questpond

Most asked JAVA Interview Questions & Answers.
Most asked JAVA Interview Questions & Answers.Most asked JAVA Interview Questions & Answers.
Most asked JAVA Interview Questions & Answers.Questpond
 
30 C# Interview Questions and Answers
30 C# Interview Questions and Answers30 C# Interview Questions and Answers
30 C# Interview Questions and AnswersQuestpond
 
Explain Delegates step by step.
Explain Delegates step by step.Explain Delegates step by step.
Explain Delegates step by step.Questpond
 
AOT(Ahead Of Time)
AOT(Ahead Of Time)AOT(Ahead Of Time)
AOT(Ahead Of Time)Questpond
 
What is CLS in .NET programming.
What is CLS in .NET programming.What is CLS in .NET programming.
What is CLS in .NET programming.Questpond
 
Explain CTS in detail.
Explain CTS in detail. Explain CTS in detail.
Explain CTS in detail. Questpond
 
Learn .NET step by step :- What is IL code in .NET?
Learn .NET step by step :- What is IL code in .NET?Learn .NET step by step :- What is IL code in .NET?
Learn .NET step by step :- What is IL code in .NET?Questpond
 
What is Higher Language and Lower Language in programming.
What is Higher Language and Lower Language in programming.What is Higher Language and Lower Language in programming.
What is Higher Language and Lower Language in programming.Questpond
 

Plus de Questpond (8)

Most asked JAVA Interview Questions & Answers.
Most asked JAVA Interview Questions & Answers.Most asked JAVA Interview Questions & Answers.
Most asked JAVA Interview Questions & Answers.
 
30 C# Interview Questions and Answers
30 C# Interview Questions and Answers30 C# Interview Questions and Answers
30 C# Interview Questions and Answers
 
Explain Delegates step by step.
Explain Delegates step by step.Explain Delegates step by step.
Explain Delegates step by step.
 
AOT(Ahead Of Time)
AOT(Ahead Of Time)AOT(Ahead Of Time)
AOT(Ahead Of Time)
 
What is CLS in .NET programming.
What is CLS in .NET programming.What is CLS in .NET programming.
What is CLS in .NET programming.
 
Explain CTS in detail.
Explain CTS in detail. Explain CTS in detail.
Explain CTS in detail.
 
Learn .NET step by step :- What is IL code in .NET?
Learn .NET step by step :- What is IL code in .NET?Learn .NET step by step :- What is IL code in .NET?
Learn .NET step by step :- What is IL code in .NET?
 
What is Higher Language and Lower Language in programming.
What is Higher Language and Lower Language in programming.What is Higher Language and Lower Language in programming.
What is Higher Language and Lower Language in programming.
 

Dernier

UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 

Dernier (20)

UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 

OOP interview questions & answers.

  • 1. OOP Most asked interview questions On this slideshare we will be sharing Q & A which will dig through some quick basics on programming - OOP based interview question and answers.
  • 2. 1. What is OOP?  OOP Stands for Object Oriented Programming. It deals with organizing a programming language model around an object rather dealing with Actions and data rather than logic. Instead of procedural programming which is based on a list of actions OOP is created to be modelled around objects that interact with one another. 2. What is an Object in OOP?  Every Entity is considered as an object for which its characteristics can be described by using features of OOP concepts. An Object can be defined as an Instance of a Class and are basic run time entities.
  • 3. 3. What is a Class?  A Class is at the core of Object Oriented Programming A Class can be said to be a Blueprint of an object that contains functions to perform action and variable to store data. A class contains behaviour and Data in Entity. A class can inherit behaviour and data members from other classes.
  • 4. 4. Explain Encapsulation in OOP?  Data Encapsulation is the Concept of hiding all the implementation details of a class from the End-user by binding data and code into a single unit. In Encapsulation we define fields as Private as opposed to declaring it as Public. 5. What is Polymorphism?  The word Polymorphism translates to having many forms.Polymorphism can be expressed as ‘One Interface, Multiple functions’ Polymorphism lets us invoke methods of derived class through base class reference during runtime.
  • 5. 6. Explain Constructors?  A Constructor is a Special Method of a Class in a program which gets invoked when the instance of a class is created. A Constructor must have the same name as the class and it gets initialized whenever The class gets initialized whenever we access that class. A Constructor does not have a return type. It can also be overloaded and it can be used to initialize variables. There are two types of Constructors: Implicit and Explicit Constructors where implicit constructors are internally created in .Net Framework while we can declare explicit constructors as we wish.
  • 6. 7. Explain Destructors?  A Destructor cannot be manually invoked in C# It is automatically invoked when an object is to be destroyed. Name of the Destructor is the same as the Class along with being prefixed with a tilde (~). Destructor is used to clear dynamically allocated memory and free the resources to allocate to other process. Destructors do not have a return type in C#. Destructors are public by default and cannot be overloaded.
  • 7. 8. Explain Abstraction in OOP?  Abstraction is the Process of only displaying relevant information without displaying the background details. Abstract Class: Incomplete class /Partial Class Abstract Method: Incomplete function An Abstract class can contain Abstract as well as non-abstract methods. Abstract class must always be public and must be declared with the abstract keyword. An Abstract class cannot be directly instantiated.
  • 8. 9. What is Interface? An Interface can be defined as a Template and it can contain only the Signature of the class in C#. An Interface cannot contain any implementation. Multiple interface inheritance along with a single base class is possible. When an Interface is declared public then its function do not need to be declared with a public keyword. Base class must always be inherited prior to interface.
  • 9. 10. What is function overloading? Function Overloading or Method Overloading allows us to have two methods with same name but different signature. Overloading occurs at Compile time and can be called as compile time polymorphism. Method overloading can be used in the same class or a child class in C#. Method overloading can be used in C# by doing the following: Changing the number of parameters in the method, changing the order of the parameters in the method and using datatypes which are different from each other.
  • 10. 11. What is Method Overriding? Method Overriding allows us to have two methods with same name and same Signature. Method Overriding occurs at Compile time and can be called as compile time polymorphism. Method overriding is only possible in child class not inside the same class from where the method is declared. Method overriding can be done in C# by creating a method in a derived class with same parameters, same name and same return type as in base class.
  • 11. 12. What are Access Modifiers? An access specifier defines the visibility and scope of a class member in C#. C# has Four Access Modifiers: • Protected • Internal • Public •Private
  • 12. 13. What are the various types of Constructors?  There are Five types of Constructors in C#: • Default Constructor • Parameterized Constructor • Copy Constructor • Static Constructor •Private Constructor
  • 13. 14. Explain Exception Handling? In C# Exception handling features help us deal with any unexpected or exceptional situations which occur when a program is in run time. Exception handling in C# uses the try (Keyword), catch (Keyword), and finally (Keyword) keywords to try actions which may not succeed and to handle failures when you decide that it is necessary to do so final keyword executes regardless if an error occurs or not.
  • 14. 15. Explain the Difference between Abstraction and Encapsulation? Encapsulation involves wrapping and hiding properties and methods. To protect the data from the end user we use encapsulates which hides the code and data into a single unit. In C# class can be used as the best example of encapsulation. In Abstraction we only show the necessary details to the intended user.
  • 15. 16. Explain Delegates?  C# act in a similar way as to that of C and C++ Pointers. A delegate is a reference type variable that contains the reference to a function and the reference can be changed at runtime. Delegates are usually used for call-back methods and implementing events. In C# all delegates are implicitly derived from the inbuilt System.Delegate class.
  • 16. 17. What are Events?  Events are Special members of the class that invokes them. When an Action occurs a class can raise an event, which have a message that contain information’s about the event (event arguments) and send them out to the rest of the application, other parts of the application can respond to the event by executing methods called event handlers. Event handler is a method in C# that has the same signature as the event and this method is executed when the event occurs.
  • 17. 18. What are Nested Classes? Nested Class is creating a class in another class in C#. Nested Classes are instantiated separately to its parent class and are not instantiated automatically by its parent. If a nested class is declared private it can only be accessed by its parent class or other nested class along with it.
  • 18. 19. Explain Generics in OOP? Generics in C# allows us to specify the datatypes of a program which maybe used inside a class or a method when the variable is used in the program. Hence Generics allows us write a Class or Method that can work with any datatype in C#. It allows us to implement core OOP features such as Code reuse, Type Safety and performance.
  • 19. 20. Explain Inheritance? Inheritance is one of the most important concept of OOP in C#. The main purpose of Inheritance is Code Reusability and avoiding Code Duplication. Instead of creating new Data Members and Member Function for new class which already exist we can just inherit it from existing class that already contains those members.
  • 20. 21. What is the default access specifier in a class definition? Private is the default access specifier in class definition in C#. 22. What are the Types of Inheritance? The different types of Inheritance in C# are as follows: • Single Inheritance: can only be inherited into one child class. • Hierarchical Inheritance: base class can be inherited into multiple child classes • Multilevel Inheritance: Contains a class derived from a another child class. Multiple inheritance is not supported in C#.
  • 21. 23. What are Sealed Classes? Inheritance can be disabled by using the sealed keyword on a class or a method. We cannot derive other classes from it when use on a base class. Derived classes can’t override the method when used on a Method.
  • 22. 24. Explain Static Classes and Members? A Static class is the same as a non-static class apart from the difference that a static class cannot be instantiated or we use a new keyword to create a variable of class type. We can access the members of the static class by using the class name. Static members can be called even when no instance of a class has been created in C# Static members and properties cannot access the non-static events and fields in their containing type.
  • 23. 25. What is Virtual Methods? Virtual methods are methods which are compulsorily declared with the virtual keyword. The virtual keyword signifies that this method can be overridden by a child class using the override keyword. 26. What are the Types of the Polymorphism?  There two types of polymorphism : • Static Polymorphism: Object is linked with Method in Compile time. • Dynamic Polymorphism: Object is linked to Method in Runtime.
  • 24. 27. What are the Advantages of OOP?  Advantages of OOP programming are Code Reusability via Inheritance, Data Security via encapsulation, Simple User interface via Abstraction and structured class approach with Objects which allows to maintain code with easy detection of errors.
  • 25. 28. Explain Difference between an Abstract class and Interface? In C# a Class can extend only one abstract class while it can implement several interfaces. Interface can only have public members while abstract class can be private and protected. Interface can extend another Interface only while any class can extend an abstract class Interfaces cannot contain body of any of its method or data members as opposed to an abstract class which can implement methods.
  • 26. 29. Explain Multicast Delegate?  A Multicast delegate is a variable which has reference to more than one function. All the functions to which the multicast delegate point to are invoked when the Multicast delegate is invoked. There are two ways to create multicast delegate are as follows: • + or += to Subscribe a method with the delegate • - or -= to Unsubscribe a method with the delegate