suppose we have an interface & that interface contains five
methods. if a class implements that interface then we have
to bound that to give tha definition of all five methods in
that class. If we declare that class as abstract then can
we call only two methods to give the deinition of that
method & i don't want to give the definition of all the
methods? can it possible
Answer Posted / nitin
yes it is possible, just make rest of the method abstract
explictly.
Example:
public interface Human {
public void canEat();
public void canThink();
public void canTalk();
public void canImegine();
public void canLove();
}
public abstract class Man implements Human {
public abstract void canEat();
public abstract void canImegine();
@Override
public abstract void canLove();
@Override
public void canTalk() {
}
@Override
public void canThink() {
}
}
public class Nitin extends Man{
/**
* @param args
*/
public static void main(String[] args) {
}
@Override
public void canEat() {
}
@Override
public void canImegine() {
}
@Override
public void canLove() {
}
}
| Is This Answer Correct ? | 29 Yes | 1 No |
Post New Answer View All Answers
What is <> used for in java?
What is java util collection?
What is the exact difference in between unicast and multicast object? Where we will use?
What is a container in a gui?
What are the differences between include directive and include action?
What is a nested list?
What does java ide mean?
What are the two types of java programming?
Is java still relevant?
What do you mean by checked exceptions?
what is nested class in java?
How can we create objects if we make the constructor private ?
Can we use synchronized block for primitives?
Is there any way to skip finally block of exception even if some exception occurs in the exception block?
What is the default value of local and global variables?