Results 1 to 2 of 2
Thread: Calling base class methods
- 11-15-2011, 10:31 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 60
- Rep Power
- 0
Calling base class methods
Let's say I have the following 3 classes. Class C extends B, and B extends A.
Is it possible within C to call A's mothod myMethod()? If so, how?
Thanks!
--------------
class A {
public void myMethod()
{
/* ... */
}
}
class B extends A {
}
class c extends B {
// Can I call class A's myMethod()?
}
- 11-15-2011, 10:47 PM #2
Re: Calling base class methods
Not directly. A class can call a method in the parent class by using the super keyword. So you would need class C to call a method in class B which would call a method in class A. However, if you plan on creating methods just to facilitate this then I have to question your design and what you are trying to do.
Similar Threads
-
how to initialize base class variable without creating object for that?
By kaka in forum New To JavaReplies: 3Last Post: 09-29-2010, 09:26 AM -
Calling methods into another class? Help please!
By javanator in forum New To JavaReplies: 1Last Post: 03-20-2010, 06:19 PM -
'Class' Object and calling Static Methods?
By mikeiz404 in forum Advanced JavaReplies: 3Last Post: 01-24-2009, 12:58 PM -
'Class' Object and calling Static Methods?
By mikeiz404 in forum New To JavaReplies: 2Last Post: 01-24-2009, 05:10 AM -
need help calling methods
By lowpro in forum New To JavaReplies: 2Last Post: 11-15-2007, 09:53 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks