What is the use of an interface?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

In a container there are 5 components. I want to display the all the components names, how will you do that one?

604


What are the 6 boolean operators?

547


What is the locale class in java programming?

525


What access modifiers can be used for class ?

534


What is set in java?

522






Why we use set in java?

514


Is it compulsory for a try block to be followed by a catch block in java for exception handling?

589


What is a null point?

557


Explain the private field modifier?

607


Explain the different forms of polymorphism?

561


What is linked hashmap and its features?

538


If a variable is declared as private, where may the variable be accessed?

546


Tell me about your ability to work under pressure

1765


What is use of set in java?

488


What super () does in java?

482