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

What is main function purpose?

517


What is the static method?

563


How can I right-justify a string?

619


What is meant by flickering?

650


What is ascii code?

634






What is style and indentation?

546


What is the difference between a method and a procedure?

540


Give me some null interfaces in java?

598


What is vector capacity in java?

593


What is java in layman terms?

521


State some advantages of java?

708


Difference between a class and an object?

571


What are the two categories of data types in the java programming language?

500


What does it mean to flush a file?

564


What is the difference between inner class and nested class?

545