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


Please Help Members By Posting Answers For Below Questions

I don’t want my class to be inherited by any other class. What should I do?

801


Given a singly linked list, find the middle of the list in a single traversal without using temporary variable.

835


What is the collection interface?

816


What is the difference between arraylist and hashset in java?

778


What is volatile data type?

745


What are assembly attributes?

768


How do you stop a thread in java?

824


What is an infinite loop in java? Explain with an example.

800


What are encapsulation, inheritance and polymorphism?

738


What is jpa specification?

737


Can we overload the constructors?

758


Explain scope or life time of local variables in java?

792


What are the concepts of 'OOPS'?

829


What does serializing data mean?

731


What is the purpose of the system class in java?

777