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

Can size_t be negative?

0 Answers  


What is tcp ip in java?

0 Answers  


What is an object in Java and what are its benefits?

4 Answers   IBM,


Create a form of user Login in JSP, that accepts the user name and password from user and authenticate it with user names and passwords stored in database. (Plz provide me answer immediately)

1 Answers   ABC,


what is thread? What are the high-level thread states? : Java thread

0 Answers  






why to use transient variables when static variables can be used for Serialization

4 Answers  


can java object be locked down for exclusive use by a given thread? : Java thread

0 Answers  


Explain when classnotfoundexception will be raised ?

0 Answers  


How big is a pointer?

0 Answers  


Can we create our own wrapper class in java?

0 Answers  


What is get () in java?

0 Answers  


How many bits is size_t?

0 Answers  


Categories