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
Define interface in java?
What does 3 dots mean in java?
What is the difference between processes and threads?
When the constructor of a class is invoked?
What is the purpose of javac exe?
What are the types of collections in java?
Explain the difference between protected and default access.
What is not thread safe?
Which java ide is used the most?
Explain notifyall() method of object class ?
What is difference between == and === in js?
What is args length in java?
What are abstract classes and anonymous classes?
Can a class have multiple constructors?
How to implement a multithreaded applet?