Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7538305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:05:21+00:00 2026-05-30T07:05:21+00:00

public int Add(int a, int b) public float Add(int a, int b) returned type

  • 0
public int Add(int a, int b) 
public float Add(int a, int b) 

returned type is different.

is this overloading or overriding ?

and what if access type is different

public int Add(int a, int b) 
private int Add(int a, int b)

Can you help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:05:22+00:00Added an answer on May 30, 2026 at 7:05 am

    It’s neither: it’s invalid code. You can’t create two methods which differ only by return type. (Or by return type and access modifier…)

    If you could, it would be overloading though – overriding happens across the inheritance hierarchy, where a method in a derived class overrides a virtual method declared in a base class. In this case, you’ve given no indication that they’re in different classes.

    The biggest difference between overloading and overriding is when the decision is made about which method to use: the compiler picks the signature based on the compile-time types, and then the implementation is chosen based on the execution-time type of the actual object.

    So if method Derived.M(int) overrides Base.M(int), then the compiler doesn’t care – it just knows it’s calling Base.M(int) and lets the CLR take care of the virtual dispatch.

    However, if there are methods Foo.M(int) and Foo.M(float) then the compiler decides at compile-time which of those will be used. (Of course, they could be virtual with overrides involved as well.)

    It’s worth noting that overloading across an inheritance hierarchy can be interesting, too – I’ve got a whole article about overloading which lists some of the oddities you might come across.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple. If I use: public void Add(params int[] values) Then I can use this
I have this class public class Room{ private int n_bed; private float cost; private
#include<iostream> class name { public: int a; name():a(0){}; }; void add(name * pname) {
public void test() { List<int> list = new List<int>(); list.Add(1); list.Add(2); list.Add(3); for (int
[DataMember] public int? NumberOfPages; //////////// Is this supported???? [DataMember] public bool? Color; //////////// Is
This compiles: class Ex1 { public int show() { try { int a=10/10; return
Consider the code public class Base { public virtual int Add(int a,int b) {
I have static java methods which I add to javascript with this method: public
public class MyClass { public int Age; public int ID; } public void MyMethod()
public class JsonCategoriesDisplay { public JsonCategoriesDisplay() { } public int CategoryID { set; get;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.