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 static import?
What is the purpose of lambda expressions?
What does %d do in java?
Why deletion in linkedlist is fast than arraylist?
Difference between this() and super() in java ?
Can you explain the meaning of aggregation and composition
What does jre stand for?
Difference between error and exception
How will you reverse a link list without using recursion?
How to set the permissions to a file in java?
Where will it be used?
If two threads have same priority which thread will be executed first ?
Does substring create a new object?
In a program, initializing an array of 100 KB is throwing an out of memory exception while there is 100 MB of memory available. Why?
Can we define static methods inside interface?