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

Explain serialization and deserialization in java?

555


Can a function return a function?

550


What is the difference between checked exception and unchecked exception?

530


Is main is a keyword?

582


What state is a thread in when it is executing?

528






Can It is possible to synchronize the constructor of a Java Class?

592


What are different data types?

570


What is the difference between the size and capacity of a vector?

569


What does \ mean in regex?

624


How do you escape a string?

508


What are strings in physics?

546


What is difference between identifier and variable?

475


What is the best definition for data?

521


What is a boolean flag in java?

567


Explain restrictions for using anonymous inner classes?

589