-
January 30th, 2012, 09:11 AM
#1
How to override a method in Java, but still have partial functionality of the parent
This question was asked during job interview, Java Development, student position.
interface someInterface
{
}
class A implements someIterface
{
}
The question is: New developer was asked to create a class that extends class A, and create method named Execute, this method will do some thing. How we should to rewrite the above code in order to have an output "start process" when method Execute is called (of course the printing should not be done in class B).
class B extends A
{
public void Execute()
{
//some code goes here
}
}
I know that it can be done with two functions and one of them is abstract. Please advise...
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|