What is the use of an interface?

Answers were Sorted based on User's Feedback



What is the use of an interface?..

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

What is the use of an interface?..

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

What is the use of an interface?..

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

Post New Answer

More Core Java Interview Questions

Explain about sets?

0 Answers  


What is the size of an array?

0 Answers  


What are the advantages of packages in java?

0 Answers  


Java support what type of parameter passing ?

7 Answers   Wipro,


Which class contains a method: cloneable or object?

0 Answers  






What is the driver class?

0 Answers  


Explain exception chaining in java?

0 Answers   Cyient,


What are the escape sequences in java?

0 Answers  


A abstract class extending an abstract class.Super class has both abstract and non-abstract methods.How can we implement abstract and non-abstract mehtods? Explain with snippet

3 Answers  


What is the difference between state-based unit testing and interaction-based unit testing?

0 Answers  


which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?

6 Answers   HP, SparkTG,


what are the major differences between jdk1.4 and jdk1.5?

2 Answers   Cap Gemini, Crimson Logic, Infosys, TCS, Tenth Planet,


Categories