Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
java abstract class constructor & extends?
I need to Initialises the people, and set the name & weight of them as below
here it is : john , 55
alan , 45
joe , 40
alice, 40
kate , 60
public abstract class people {
public String john, alan, joe, alice, kate;
public people(String name, int weight)
{
weight = 55;
weight = 45;
weight = 40;
weight = 40;
weight = 60;
name = john;
name = alan;
name = joe;
name = alice;
name = kate;
}
public String getName()
{
return name; // ????
}
}
public class john extends people {
public john()
{
super(); // cant find symbol - constructor people()!!
weight = 55;
}
so basically , what I'm tring to do is Initialises both super&sub
class but it won't work. And i was trying to make a method that return
the name and another returning the weight but i can't .
I'm quite new to java stuffs so it would be very kind if you
point me to the right direction.
btw. cant change/touch any of method signature.
2 Answers
- Neeraj Yadav♥Lv 61 decade agoFavorite Answer
You are supposed to use
super(name, weight);
and make name as static
static String name;
this will help
Cheers:)
- 1 decade ago
can you be more specific? or try going to www.youtube.com and type in your question
Source(s): personal experience