I have a doubt regarding the excersise 1.1 page 18-K&B book(with my scenario) If i create the abstract class Fruit, say the class contains abstract method x() and non-abstract methods y() and z(), and if i make Apple class(abstract) extending the Fruit class. Then there is no way i can access the non-abstract methods of class Fruit from Apple though it is extending it(bcoz i cant create objects for Apple class as its abstract). I would like to know if there is any way i can access the non-abstract methods of Fruit class from Apple class bcoz Apple extends Fruit?
Thanks in advance Asha
David McCombs
Ranch Hand
Joined: Oct 17, 2006
Posts: 212
posted
0
As long as those methods in fruit are not private you should be able to call them from Apple.
"Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration."- Stan Kelly-Bootle
asha ganapathy
Ranch Hand
Joined: Nov 03, 2006
Posts: 54
posted
0
The non-abstract methods in the Fruit class are not private, then how do i call them from Apple which is an abstract class?
asha ganapathy
Ranch Hand
Joined: Nov 03, 2006
Posts: 54
posted
0
This is a different Scenario.. :roll: I found that an Abstract class can extend Non-Abstract class.i would like to know where kind of inheritance is used?
dhwani mathur
Ranch Hand
Joined: May 08, 2007
Posts: 621
posted
0
Hey asha as you have mentioned that both Fruit and Apple are abstrat classes and you want to inherit the nonabstarct methods of super class Fruit in apple
You must be knowing that abstract classes do not consist of implementation of methods just methods are declared,and still you want to get the non abstract methods in the abstract class apple you just override those methods as shown in below code..........