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



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

Answer / 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

More Core Java Interview Questions

How many objects are created when we create String class object using new operator?

9 Answers   Mind Tree,


If we don’t want some of the fields not to serialize how to do that?

0 Answers  


What is a ternary operator in java? What is an interface?

0 Answers  


Can we override constructor in java?

0 Answers  


What is collection sort in java?

0 Answers  






How do you sort a string in java?

0 Answers  


what is request processor?

1 Answers   Virtusa,


How do you check if a string is lexicographically in java?

0 Answers  


Can a class have a static inner class?

0 Answers  


What is class and object in java?

0 Answers  


What is the difference between ArrayList and Vector? which one is better in Java

0 Answers   SkillGun Technologies,


What things should be kept in mind while creating your own exceptions in java?

0 Answers  


Categories