How to define an Interface?

By: Karthik  

Answer: In Java Interface defines the methods but does not implement them. Interface can include constants. A class that implements the interfaces is bound to implement all the methods defined in Interface.

Example of Interface:

public interface sampleInterface {
    public void functionOne();
    public long CONSTANT_ONE = 1000; 
} 



Archived Comments


Most Viewed Articles (in Interview )

What are the life-cycle methods of JSP?

What is the difference between JTS and JTA?

Interview Question: What is ActionForm?

Interview Question: How many EJB Objects are created for a Bean?

What is the difference between Session Bean and Entity Bean?

Tell me something about J2EE component?

Question: What is the directory structure of a web application?

Question: Explain the life-cycle methods in JSP?

Question: What is a Hidden Comment in JSP?

Interview Question: Can i map more than one table in a CMP?

Interview Question: Can I invoke Runtime.gc() in an EJB?

Interview Question: Why does EJB needs two interfaces(Home and Remote Interface)?

Interview Question: What is the difference between sessioncontext and entitycontext?

Interview Question: What are the call back methods in Entity bean?

Interview Question: What is lazy loading?

Latest Articles (in Interview)

Comment on this tutorial