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
Under what conditions is an object’s finalize() method invoked by the garbage collector?
How do you start a new line in java?
Is stringwriter thread safe?
What is the epoch date?
How objects of a class are created if no constructor is defined in the class?
Why we do exception handling in java and how many types of exceptions are there?
When we should use serialization?
Discuss different types of errors that generally occur while programming.
What is xslt in java?
What’s the difference between constructors and other methods?
How is a structure different from array ?
Can a lock be acquired on a class in java programming?
How will you reverse a singly-link list?
Is double bigger than float?
Can we print null in java?