Any one can explain how the inerface uses in java. give with
example.

Answer Posted / yogesh sanas

Interface is a contract between class and interface. Interface has some public abstract methods which class needs to be implement.

We can achieve polymorphism using Interface.

e.g.
Interface Interface_Name(){
int add(int x, int y);
}

Class MyClass implements Interface_Name{
public int add(int x, int y){
return x+y;
}
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a list in java?

502


How to implement an arraylist in java?

504


Why does java have two ways to create child threads?

464


What do you understand by Header linked List?

590


What will happen to the exception object after exception handling?

568






Define how objects are stored in java?

559


Why super is first line in java?

552


Can an object subclass another object?

552


Explain what do you mean by functional overloading in java?

553


What is a protected class in java?

532


What is substring 1 in java?

589


How many bytes is a unicode character?

502


what is object slice?

1572


Is string is a class in java?

519


Can we create a constructor in abstract class?

567