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

Is a class subclass of itself?

605


What is a parameter in java?

548


Can we catch more than one exception in a single catch block?

629


Can we cast any other type to boolean type with type casting?

539


How do you sort words in java?

538






explain what is transient variable in java?

627


Are primitives objects?

566


How can we create a thread in java?

589


What is the disadvantage of java?

508


What is the numeric promotion?

503


What is ternary operator in java?

596


What is size_t?

507


Does it matter in what order catch statements for filenotfoundexception and ioexception are written?

506


Can you change array size in java?

532


What do you mean by exception handling in Java?

662