File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Abstract class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Abstract class" Watch "Abstract class" New topic
Author

Abstract class

asha ganapathy
Ranch Hand

Joined: Nov 03, 2006
Posts: 54
Hi All,

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
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
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
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
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..........




i hope it helps you.......
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Abstract class
 
Similar Threads
Getting it right from the beginning : Object vs Reference
The 'DateFormat' abstract class
class design problem
abstract and static
Visibility of inherited method