How to define an Interface?

By: Karthik Printer Friendly Format    


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; 
} 


Most Viewed Articles (in Interview )

What are types of J2EE clients?

Interview Question: Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?

Explain the Polymorphism principle.

Interview Question: What is Struts?

Interview Question: Why do we need Struts?

Interview Question: What is EJB container?

Interview Question: What is lazy loading?

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

Interview Question: What is local interface. How values will be passed?

What is Deployment Descriptor?

What are all the different scope values for the tag?

Interview Question: How is the MVC design pattern used in Struts framework?

Interview Question: Who makes the Struts?

Interview Question: Why it is called Struts?

Interview Question: What is Action Class?

Latest Articles (in Interview)

Comment on this tutorial