473,416 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

i want to override method with different return type is it possible?

at the compile time it gives the error like
"attempting to use the incompatible return type"
Sep 15 '10 #1
3 1573
RamananKalirajan
608 512MB
It means that the return value is assigned to some other data type or object.

ex:
Expand|Select|Wrap|Line Numbers
  1. int x = getValue(val);
  2.     //some code....
  3.     public List getValue(int val){
  4.        //some code...
  5.     }
Usage of codes like this will throw that error. Just check for whether the returned value and assigning variable type are same or not.

Thanks and Regards
Ramanan Kalirajan
Sep 15 '10 #2
Dheeraj Joshi
1,123 Expert 1GB
Method overriding means new method definition in subclass which is same as parent class. The signature of the class must be same(i.e method name,parameters and return type)

Regards
Dheeraj Joshi
Sep 16 '10 #3
RamananKalirajan
608 512MB
Sorry confused with overloading.

Thanks and Regards
Ramanan Kalirajan
Sep 16 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Murat Tasan | last post by:
so i have a situation that i know cannot be solved directly, and i've already worked around it, but i was hoping to find an explanation as to why this behavior is as it is... i have an abstract...
1
by: Steven.Xu | last post by:
Hi every one. I have two class: MyBase and MySon. MyBase is the base class of MySon. On the other hand I have two interface: MyBaseItef and MySonItef. MyBaseItef is the base interface of...
6
by: David Sobey | last post by:
Hi everyone I'm having huge difficulties overriding or hiding a base function with a function that returns a covariant type. I'd be grateful if someone could show me some code where this is...
5
by: Brad Wood | last post by:
It doesn't look like something like this is possible in 2.0: public <T> doStuff(); Am I correct, and if so, there's probably a good reason that I can't think of why not...
9
by: hufaunder | last post by:
I have a class "TestSuper" that implements the interface "TestBase". The interface has a property of type "ReturnType". The class "TestSuper" does not return "ReturnType" but a derivation...
1
by: PengYu.UT | last post by:
Hi, Are there any walkaround to enable functions in the derived class with the same function name but different return type? In the following example, D1 and D2 are B's derived class. I want...
1
by: eshortt84 | last post by:
hey, i'm new to java and i keep getting the return type required error on this line; public dvds(int productNum, String name, int units, double price, String rating) { The code for the whole...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.