SlideShare a Scribd company logo
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

More Related Content

What's hot

Operators in java
Operators in javaOperators in java
Operators in java
Then Murugeshwari
 
OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
Thooyavan Venkatachalam
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
Muhammad Waqas
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
harsh kothari
 
Principles and advantages of oop ppt
Principles and advantages of oop pptPrinciples and advantages of oop ppt
Principles and advantages of oop ppt
daxesh chauhan
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
Madishetty Prathibha
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
Ronak Chhajed
 
Introduction to method overloading & method overriding in java hdm
Introduction to method overloading & method overriding  in java  hdmIntroduction to method overloading & method overriding  in java  hdm
Introduction to method overloading & method overriding in java hdm
Harshal Misalkar
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
Iqra khalil
 
the Concept of Object-Oriented Programming
the Concept of Object-Oriented Programmingthe Concept of Object-Oriented Programming
the Concept of Object-Oriented ProgrammingAida Ramlan II
 
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
Sujith Kumar
 
Javapolymorphism
JavapolymorphismJavapolymorphism
Javapolymorphism
karthikenlume
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
Vishwa Mohan
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
tigerwarn
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
Nilesh Dalvi
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
CPD INDIA
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
Elizabeth alexander
 
Object-Oriented Programming Concepts
Object-Oriented Programming ConceptsObject-Oriented Programming Concepts
Object-Oriented Programming Concepts
Kwangshin Oh
 

What's hot (20)

Operators in java
Operators in javaOperators in java
Operators in java
 
OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
 
Inheritance
InheritanceInheritance
Inheritance
 
Principles and advantages of oop ppt
Principles and advantages of oop pptPrinciples and advantages of oop ppt
Principles and advantages of oop ppt
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
Introduction to method overloading & method overriding in java hdm
Introduction to method overloading & method overriding  in java  hdmIntroduction to method overloading & method overriding  in java  hdm
Introduction to method overloading & method overriding in java hdm
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
the Concept of Object-Oriented Programming
the Concept of Object-Oriented Programmingthe Concept of Object-Oriented Programming
the Concept of Object-Oriented Programming
 
File handling in c++
File handling in c++File handling in c++
File handling in c++
 
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
 
Javapolymorphism
JavapolymorphismJavapolymorphism
Javapolymorphism
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Object-Oriented Programming Concepts
Object-Oriented Programming ConceptsObject-Oriented Programming Concepts
Object-Oriented Programming Concepts
 

Similar to 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 answer
Jeba Moses
 
Data Structure Interview Questions & Answers
Data Structure Interview Questions & AnswersData Structure Interview Questions & Answers
Data Structure Interview Questions & Answers
Satyam Jaiswal
 
C++ interview question
C++ interview questionC++ interview question
C++ interview question
Durgesh Tripathi
 
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
Sanjaya Prakash Pradhan
 
OOP in Java Presentation.pptx
OOP in Java Presentation.pptxOOP in Java Presentation.pptx
OOP in Java Presentation.pptx
mrxyz19
 
software engineer interview questions.pdf
software engineer interview questions.pdfsoftware engineer interview questions.pdf
software engineer interview questions.pdf
RaajpootQueen
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
Ajay Chimmani
 
C# interview
C# interviewC# interview
C# interview
Thomson Reuters
 
Php oop (1)
Php oop (1)Php oop (1)
Php oop (1)
Sudip Simkhada
 
C# interview
C# interviewC# interview
C# interview
ajeesharakkal
 
Unusual C# - OOP
Unusual C# - OOPUnusual C# - OOP
Unusual C# - OOP
Medhat Dawoud
 
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
w3asp dotnet
 
C#
C#C#
C# interview questions
C# interview questionsC# interview questions
C# interview questions
Chetan Chaudhari
 
Android interview questions
Android interview questionsAndroid interview questions
Android interview questions
satish reddy
 
Android interview questions
Android interview questionsAndroid interview questions
Android interview questions
satish 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
 

Similar to 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
 
software engineer interview questions.pdf
software engineer interview questions.pdfsoftware engineer interview questions.pdf
software engineer interview questions.pdf
 
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..........
 

More from 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 Answers
Questpond
 
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
 

More from 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.
 

Recently uploaded

Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 

Recently uploaded (20)

Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 

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