Question:
When you declare a method as abstract, can other nonabstract methods access it?
Answer:
Yes, other nonabstract methods can access a method that you declare as abstract. Source: CoolInterview.com
No, Abstract method has only definition no implementation so other methods cannot access it until and unless we provide the body in the sub class.
Source: CoolInterview.com
Answered by: Mohan | Date: 11/16/2009
| Contact Mohan
Yes , non abstract method can access abstract method , but this abstract method will be implemented in its subclass and the same will be invoked from the non abstarct method of abstract super class. if not implemented the subclass must also be an abstract class. so doesn't create any issue. Instance can't be created for the same . Source: CoolInterview.com
Answered by: Yathiraja | Date: 12/8/2009
| Contact Yathiraja
abstract class Abc { abstract int hello(); int hai() { hello(); return 1; } }
Yes, we can access the abstract method from non abstract methods, this way, this got compiled with no errors. Source: CoolInterview.com
Answered by: Venkat | Date: 3/17/2010
| Contact Venkat
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|