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 Acces sub members from base Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Acces sub members from base" Watch "Acces sub members from base" New topic
Author

Acces sub members from base

cornel jew
Ranch Hand

Joined: Jul 13, 2002
Posts: 37
Hi all
I was coding using inheritance and need to know the following:
Can your base class acces additional members of your sub class, and if yes can you give some example.

Thanks for any help
cornel
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
No. If you are referring to methods, there is a way to work around this. If you make your base class abstract, you can add those methods as abstract methods. You can then call those methods from the methods that you implement in the base class. You can implement those abstract methods in the sub class and instantiate it in the calling class.


Matthew Phillips
Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
A general rule of thumb.
A child can always reference a variable or method
of it's parent or grand-parent. Scope of variable or method not being considered at this time.
A parent can NOT reference a child's variables or methods. Casting of data types is not being considered at this time.
This is a beginners form.
We are all here to help and learn.


Multi Platform Database Developer & DBA on E.S.T.
cornel jew
Ranch Hand

Joined: Jul 13, 2002
Posts: 37
Hi
Thanks for the respond and answer now i am satisfied, cos i was somewhat puzzled.
Yours
Cornel
 
IntelliJ Java IDE
 
subject: Acces sub members from base
 
Threads others viewed
cast
Casting urgently! Marcus Green Exam1
Sub Class Error
method and variable accessibility
plz explain the o/p
IntelliJ Java IDE