Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

crazy vi

Greenhorn
+ Follow
since Jul 04, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by crazy vi

Hi,

How i can find the difference in method overriding and overloading with regard to below program. And also how to find valid overload and valid override with regard to the below code.
class Big{
void doStuff(int x){ }
}
class Heavy extends Big{
//tell me whether below statement is valid overload /override
void doStuff(byte b){}
protected void doStuff(int x)throws Exception{}
}
public class Weighty extends Heavy{
void doStuff(int x);
//tell me whether below statement is valid overload /override
String doStuff(int x){return "hi";}
public int doStuff(int x){return 7;}
//tell me whether below statement is valid overload /override
private int doStuff(char c) throws Error{return 1;}
}

i have added comment to the code which explains my doubt. Can anyone explain the reason as well? I took the above example from ocp practice exams by K&B
Thank you campbell for your response.
9 years ago