SlideShare a Scribd company logo
Differences between method overloading and method overriding 
Answer: 
Method Overloading and Method Overriding are both the techniques used to implement FUNCTIONAL 
POLYMORPHISM 
They enhance the methods functionality using their respective features. 
overloading: 
1) It involves having another method with the same name in a class or its derived class. 
2)can be implemented with or without inheritance. 
3)It is implemented by: 
a)changing the number of parameters in different methods with same name. 
b)changing the parameter data types (if the number of parameters are same) 
c)changing parameter order. 
4)applicable to static as well as non static methods: 
5)no keywords needed before the method names in C#. 
6)also called as COMPILE TIME Polymorphism. 
example: int add(int a, int b) 
{ 
return a+b; 
} 
int add(int a) 
{ 
return a*5; 
} 
Overriding: 
1) It involves having another method with the same name in a base class and derived class.
2)always needs inheritance. 
3)It is implemented by having two methods with same name, same signature, but different 
implementations (coding)in a base class and derived class 
4)applicable to nonstatic, nonprivate methods only.access modifiers of the methods are not changed in 
the base and derived classes. 
5)virtual and override keywords are needed before the method names in base and derived classes. 
For overriding in firther classes, override keyword will be used, 
6)RUN TIME Polymorphism 
example: 
class A 
{ 
public virtual void demo() 
{ 
} 
} 
class B:A 
{ 
public override void demo() 
{ 
} 
static void Main() 
{ 
B obj=new B(); 
obj.demo(); 
} 
} 
What is CLS? 
Answer: 
CLS: 
Common Language Specification:
It is a set of the programming rules which every .NET language must follow. 
CLS is used so that the code written in one language is interoperable with the code written in 
another language. The different .NET languages code is compiled into MSIL Code. CLS defines 
the infrastructure for the MSIL Code. The CLR processes the MSIL code and help in its 
execution. This ensures the language interoperability. 
EXAMPLES OF CLS: 
1)Common set of data types for all the languages( CTS) 
Int32 datatype is implemented as int in C# and as integer in VB.NET 
2)Interfaces cannot have static methods.It applies to all the .NET languages. 
The Types which follow the CLS rules are also called as CLS Compliant types. 
CLS compliant languages: 
VB.NET,C#, VC++ 
Use of CLS: 
A class written in VB.NET can be used in C# and vice-versa. 
For the complete list of CLS features, please visit this link. 
http://msdn.microsoft.com/en-us/library/12a7a7h3(VS.71).aspx 
What is .NET Framework? 
Answer: 
.NET (.Network Enabled Technologies) is a collection of development tools 
developed by the Microsoft Corporation that enables the developers to develop 
and execute a large variety of applications 
example: Console,Windows,Web,WPF,WCF, Web Services, Window Services, 
Mobile Applications.
.NET Framework consists of: 
1)CLR: (Common Language Runtime): 
2)FCL: (Framework Class Llivraries) 
3)Languages, Language Compilers 
CLR is the set of components(also called as the execution engine) and provides 
us with many runtime services. 
example: 
1)Managing code execution. 
2)Menory management and Garbage Collection. 
3)Exception handling management 
4)Security and Code Verification 
5)MultiThreading support 
6)Cross Language interoperability using CTS and CLS. 
FCL provides us with the predefined class libraries which have over thousands of 
classes that can be used in development and execution. 
example: System.Data.dl 
System.Windows.Forms.dll 
System.dll 
mscorlib.dll 
Languages :example: VB.NET, C#,VC++ 
Each language ahs its own set of compilers 
ex: vbc for vb.net, csc for csharp. 
Coompilers are used to compile the code and generate the executable files.(Assemblies) 
What is difference between out and ref in c#? 
Answer: 
This is a great .NET Interview question and also very very confusing question. By default parameters are 
always passed by value to methods and functions.If you want to pass data byref then you can use either 
out or ref keyword. 
There are two big difference between these keywords one is the way data is passed between the caller 
code and method and second who is responsible for initialization.
Way the data is passed(directional or bi-directional) 
================================================== 
When you use OUT data is passed only one way i.e from the method to the caller code. 
When you use REF , Data can be passed from the called to the method and also vice versa. 
Who initializes data 
============================================== 
In OUT the variables value has to be intialized in the method. In REF the value is initialized outside the 
method by the caller. 
The most important thing the interviewer will like to hear from you When to use when 
====================================================== 
OUT will be used when you want data to be passed only from the method to the caller. 
REF will be used when you want data to be passed from the called to the method and also vice versa. 
My 100 .NET Interview questions http://www.questpond.com 
What is the difference between .NET 1.1,2.0,3.0,3.5 and 4.0 ? 
Answer: 
The list of differences are huge. In interviews you normally need to short and sweet. So we will list down 
top 5 differences from each section. 
So lets first start with the difference between 1.0 and 2.0. 
Support for 64 bit application. 
Generics 
SQL cache dependency 
Master pages 
Membership and roles 
Now the next difference .NET 2.0 and 3.0 
========================================= 
WCF 
WPF 
WWF 
WCS ( card space) 
3.0 and 3.5
========================================== 
LINQ 
Ajax inbuilt 
ADO Entity framework 
ADO data services 
Multi targeting 
Finally 3.5 and 4.0 
=========================================== 
MEF 
Parallel computing 
DLR dynamic 
Code contract 
language runtime 
Lazy initialization 
Differences between Window and Web Forms 
Answer: 
Window Forms: 
1)They do not need a web browser or web server to execute. 
2)They execute through their respective exe files 
3)They run on the same machine they are displayed on. 
4)Their single instance exists until we close them or dispose them through coding 
5)Used for developing games, inventory management, system utiltites etc. 
6)They run under Code Access Security. 
Web Forms: 
1)They need a web browser as well as a web server(on the server machine only). 
2)They execute through the dll of the web application which is then processed by IIS and the .net
framework. 
3)They run on a remote server and are displayed remotely on the clients. 
4)Every time they are submitted, their new instance is created. 
5)Used in web site development. 
6)They use role based security

More Related Content

What's hot (20)

PPTX
Introduction to C++ Programming
Preeti Kashyap
 
PDF
C++ Object oriented concepts & programming
nirajmandaliya
 
PPTX
Static Data Members and Member Functions
MOHIT AGARWAL
 
PDF
Intake 37 linq1
Mahmoud Ouf
 
PDF
Intake 37 1
Mahmoud Ouf
 
PPT
C++ overloading
sanya6900
 
PDF
Intake 37 linq2
Mahmoud Ouf
 
PDF
Function overloading
Prof. Dr. K. Adisesha
 
PPTX
Java 8 new features
Aniket Thakur
 
PPTX
Java Tutorial Lab 5
Berk Soysal
 
PPT
Type conversions
sanya6900
 
PDF
Intake 37 ef2
Mahmoud Ouf
 
PPT
Linq
Vishwa Mohan
 
PPTX
Data members and member functions
Marlom46
 
PDF
Intake 37 2
Mahmoud Ouf
 
PPTX
Java Tutorial Lab 1
Berk Soysal
 
PPT
Understanding linq
Anand Kumar Rajana
 
PPTX
Inheritance
Jaya Kumari
 
PPTX
Function overloading
zindadili
 
PDF
Inheritance
Pranali Chaudhari
 
Introduction to C++ Programming
Preeti Kashyap
 
C++ Object oriented concepts & programming
nirajmandaliya
 
Static Data Members and Member Functions
MOHIT AGARWAL
 
Intake 37 linq1
Mahmoud Ouf
 
Intake 37 1
Mahmoud Ouf
 
C++ overloading
sanya6900
 
Intake 37 linq2
Mahmoud Ouf
 
Function overloading
Prof. Dr. K. Adisesha
 
Java 8 new features
Aniket Thakur
 
Java Tutorial Lab 5
Berk Soysal
 
Type conversions
sanya6900
 
Intake 37 ef2
Mahmoud Ouf
 
Data members and member functions
Marlom46
 
Intake 37 2
Mahmoud Ouf
 
Java Tutorial Lab 1
Berk Soysal
 
Understanding linq
Anand Kumar Rajana
 
Inheritance
Jaya Kumari
 
Function overloading
zindadili
 
Inheritance
Pranali Chaudhari
 

Viewers also liked (12)

PDF
Lo2
liankei
 
PDF
Csharp_Chap03
Mohamed Krar
 
PPT
Visula C# Programming Lecture 6
Abou Bakr Ashraf
 
PPTX
Object Oriented Programming with C#
foreverredpb
 
PPT
Csc153 chapter 07
PCC
 
PPT
Method overriding
Azaz Maverick
 
PDF
20 most important java programming interview questions
Gradeup
 
PPTX
Object Oriented Programming - Value Types & Reference Types
Dudy Ali
 
PPT
Programming in c#
Shehrevar Davierwala
 
PDF
Important java programs(collection+file)
Alok Kumar
 
PPTX
Slideshare.Com Powerpoint
guested929b
 
PPTX
Slideshare ppt
Mandy Suzanne
 
Lo2
liankei
 
Csharp_Chap03
Mohamed Krar
 
Visula C# Programming Lecture 6
Abou Bakr Ashraf
 
Object Oriented Programming with C#
foreverredpb
 
Csc153 chapter 07
PCC
 
Method overriding
Azaz Maverick
 
20 most important java programming interview questions
Gradeup
 
Object Oriented Programming - Value Types & Reference Types
Dudy Ali
 
Programming in c#
Shehrevar Davierwala
 
Important java programs(collection+file)
Alok Kumar
 
Slideshare.Com Powerpoint
guested929b
 
Slideshare ppt
Mandy Suzanne
 
Ad

Similar to Differences between method overloading and method overriding (20)

DOC
C# interview questions
Chetan Chaudhari
 
PPTX
DOT NET Framework.pptxdsfdsfdsfsdfdsfdsfdsf
zmulani8
 
DOC
C# interview
ajeesharakkal
 
PDF
C# c# for beginners crash course master c# programming fast and easy today
Afonso Macedo
 
PDF
C# interview-questions
nicolbiden
 
DOCX
Mit4021 c# and .net
smumbahelp
 
PDF
Cognizant Interview Questions By ScholarHat.pdf
Scholarhat
 
PDF
Dot NET Interview Questions PDF By ScholarHat
Scholarhat
 
PDF
C language 100 questions answers
sakshitiwari631430
 
PPTX
Top TCS Interview Questions And Answers | How to Crack An Interview At TCS | ...
Simplilearn
 
PPT
Dotnetintroduce 100324201546-phpapp02
Wei Sun
 
PDF
Entity Framework Interview Questions PDF By ScholarHat
Scholarhat
 
DOCX
C# note
Dr. Somnath Sinha
 
PDF
Dotnet interview qa
abcxyzqaz
 
PDF
Dot net
public
 
PDF
Asp.net main
YogeshDhamke2
 
PDF
C++ programing lanuage
Nimai Chand Das
 
DOCX
C# Unit 1 notes
Sudarshan Dhondaley
 
PDF
Dot net interview questions and asnwers
kavinilavuG
 
PPT
Csharp
Swaraj Kumar
 
C# interview questions
Chetan Chaudhari
 
DOT NET Framework.pptxdsfdsfdsfsdfdsfdsfdsf
zmulani8
 
C# interview
ajeesharakkal
 
C# c# for beginners crash course master c# programming fast and easy today
Afonso Macedo
 
C# interview-questions
nicolbiden
 
Mit4021 c# and .net
smumbahelp
 
Cognizant Interview Questions By ScholarHat.pdf
Scholarhat
 
Dot NET Interview Questions PDF By ScholarHat
Scholarhat
 
C language 100 questions answers
sakshitiwari631430
 
Top TCS Interview Questions And Answers | How to Crack An Interview At TCS | ...
Simplilearn
 
Dotnetintroduce 100324201546-phpapp02
Wei Sun
 
Entity Framework Interview Questions PDF By ScholarHat
Scholarhat
 
Dotnet interview qa
abcxyzqaz
 
Dot net
public
 
Asp.net main
YogeshDhamke2
 
C++ programing lanuage
Nimai Chand Das
 
C# Unit 1 notes
Sudarshan Dhondaley
 
Dot net interview questions and asnwers
kavinilavuG
 
Csharp
Swaraj Kumar
 
Ad

Recently uploaded (20)

PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 

Differences between method overloading and method overriding

  • 1. Differences between method overloading and method overriding Answer: Method Overloading and Method Overriding are both the techniques used to implement FUNCTIONAL POLYMORPHISM They enhance the methods functionality using their respective features. overloading: 1) It involves having another method with the same name in a class or its derived class. 2)can be implemented with or without inheritance. 3)It is implemented by: a)changing the number of parameters in different methods with same name. b)changing the parameter data types (if the number of parameters are same) c)changing parameter order. 4)applicable to static as well as non static methods: 5)no keywords needed before the method names in C#. 6)also called as COMPILE TIME Polymorphism. example: int add(int a, int b) { return a+b; } int add(int a) { return a*5; } Overriding: 1) It involves having another method with the same name in a base class and derived class.
  • 2. 2)always needs inheritance. 3)It is implemented by having two methods with same name, same signature, but different implementations (coding)in a base class and derived class 4)applicable to nonstatic, nonprivate methods only.access modifiers of the methods are not changed in the base and derived classes. 5)virtual and override keywords are needed before the method names in base and derived classes. For overriding in firther classes, override keyword will be used, 6)RUN TIME Polymorphism example: class A { public virtual void demo() { } } class B:A { public override void demo() { } static void Main() { B obj=new B(); obj.demo(); } } What is CLS? Answer: CLS: Common Language Specification:
  • 3. It is a set of the programming rules which every .NET language must follow. CLS is used so that the code written in one language is interoperable with the code written in another language. The different .NET languages code is compiled into MSIL Code. CLS defines the infrastructure for the MSIL Code. The CLR processes the MSIL code and help in its execution. This ensures the language interoperability. EXAMPLES OF CLS: 1)Common set of data types for all the languages( CTS) Int32 datatype is implemented as int in C# and as integer in VB.NET 2)Interfaces cannot have static methods.It applies to all the .NET languages. The Types which follow the CLS rules are also called as CLS Compliant types. CLS compliant languages: VB.NET,C#, VC++ Use of CLS: A class written in VB.NET can be used in C# and vice-versa. For the complete list of CLS features, please visit this link. http://msdn.microsoft.com/en-us/library/12a7a7h3(VS.71).aspx What is .NET Framework? Answer: .NET (.Network Enabled Technologies) is a collection of development tools developed by the Microsoft Corporation that enables the developers to develop and execute a large variety of applications example: Console,Windows,Web,WPF,WCF, Web Services, Window Services, Mobile Applications.
  • 4. .NET Framework consists of: 1)CLR: (Common Language Runtime): 2)FCL: (Framework Class Llivraries) 3)Languages, Language Compilers CLR is the set of components(also called as the execution engine) and provides us with many runtime services. example: 1)Managing code execution. 2)Menory management and Garbage Collection. 3)Exception handling management 4)Security and Code Verification 5)MultiThreading support 6)Cross Language interoperability using CTS and CLS. FCL provides us with the predefined class libraries which have over thousands of classes that can be used in development and execution. example: System.Data.dl System.Windows.Forms.dll System.dll mscorlib.dll Languages :example: VB.NET, C#,VC++ Each language ahs its own set of compilers ex: vbc for vb.net, csc for csharp. Coompilers are used to compile the code and generate the executable files.(Assemblies) What is difference between out and ref in c#? Answer: This is a great .NET Interview question and also very very confusing question. By default parameters are always passed by value to methods and functions.If you want to pass data byref then you can use either out or ref keyword. There are two big difference between these keywords one is the way data is passed between the caller code and method and second who is responsible for initialization.
  • 5. Way the data is passed(directional or bi-directional) ================================================== When you use OUT data is passed only one way i.e from the method to the caller code. When you use REF , Data can be passed from the called to the method and also vice versa. Who initializes data ============================================== In OUT the variables value has to be intialized in the method. In REF the value is initialized outside the method by the caller. The most important thing the interviewer will like to hear from you When to use when ====================================================== OUT will be used when you want data to be passed only from the method to the caller. REF will be used when you want data to be passed from the called to the method and also vice versa. My 100 .NET Interview questions http://www.questpond.com What is the difference between .NET 1.1,2.0,3.0,3.5 and 4.0 ? Answer: The list of differences are huge. In interviews you normally need to short and sweet. So we will list down top 5 differences from each section. So lets first start with the difference between 1.0 and 2.0. Support for 64 bit application. Generics SQL cache dependency Master pages Membership and roles Now the next difference .NET 2.0 and 3.0 ========================================= WCF WPF WWF WCS ( card space) 3.0 and 3.5
  • 6. ========================================== LINQ Ajax inbuilt ADO Entity framework ADO data services Multi targeting Finally 3.5 and 4.0 =========================================== MEF Parallel computing DLR dynamic Code contract language runtime Lazy initialization Differences between Window and Web Forms Answer: Window Forms: 1)They do not need a web browser or web server to execute. 2)They execute through their respective exe files 3)They run on the same machine they are displayed on. 4)Their single instance exists until we close them or dispose them through coding 5)Used for developing games, inventory management, system utiltites etc. 6)They run under Code Access Security. Web Forms: 1)They need a web browser as well as a web server(on the server machine only). 2)They execute through the dll of the web application which is then processed by IIS and the .net
  • 7. framework. 3)They run on a remote server and are displayed remotely on the clients. 4)Every time they are submitted, their new instance is created. 5)Used in web site development. 6)They use role based security