What is the use of an interface?
Answers were Sorted based on User's Feedback
Answer / harathi
We can define a set of methods in an interface and
implement it in different ways in different classes
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / muthusenthil
Interface is mearly a specification, its a design flexible
it can be used to model multiple inheritance normally java
wont supports.
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / ashokmail
By using interface you can do multiple inheritance in java.
Example :
interface student{
public void add();
}
public class clloge implements student{
public clloge(){
}
public void add(){
// Some codes
}
}
public class croom implements student{
public croom(){
}
public void add(){
// Some codes
}
}
Using Interface..
public void uinter {
private student[3] stu ;
public uinter(){
stu[0] = new croom();
stu[1] = new clloge()
stu[2] = new croom();
for(int i=0;i<3;i++)
stu[i].add();
}
}
| Is This Answer Correct ? | 2 Yes | 2 No |
What is core java used for?
What is the difference between a field variable and a local variable?
What is the life-cycle of an object?
What is java util concurrentmodificationexception?
How is garbage collection controlled?
How will you print number in reverse (descending) order in BST.
What restrictions are placed on method overloading?
1.) if we use "private" in place of "public" in public static void main()... 2.) if we use "int" in place of "void".... 3.) can we ommit "static" keyword from that statement.... 4.) also can we give the command line arguments type as int type or float,etc.(.i.e (string args[]))
How many types of parsers are there?
Can vector have duplicates in java?
How to optimize the javac output?
What is stack class in java?