answersLogoWhite

0


Best Answer

An interface is a prototype for a class. The class may contains non-implemented method as well as no member variables (i.e. no variable declaration). The syntax for creating interfaces is :-
interface interface_name
{
//statements
}
The syntex for implementing interfaces using "implements" keyword is :-
class class_name implements interface_name
{
//statements
}

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

The idea is to enforce the declaration of certain methods, which may be required in certain contexts. That is, if you declare that a class implements a certain interface, then you have to write all the corresponding methods. If you don't, there will be a compile-time error.

From a design standpoint, Interfaces are what allows Java (an otherwise Single Inheritance Object Oriented Language) to mimic much of the usefulness of Multiple Inheritance designs, without also having the problem of conflicting method/Class parentage that M.I. has.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why interface concept has been introduced in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is api in java?

API is an Application Programming Interface..that means Some collection for designing concept for GUI(Graphical User INterface) By Saravanan


Can you create a constructor for an interface in java?

NO, we cannot create a contructor for an interface in java.


Can you define variables in interface in java?

yes we can define a variable in an interface in java.


When Java Swings Introduced?

Java Swings was introduced in 1997.


What is intrface in java?

interface is a list of methods which implements that interface


What is a tagging interface type?

A tagging interface type in Java is an interface that has not defined methods such as the java.io.Serializable interface.


How does java support the concept of destructer in java?

In Java, Java does support the concept of destructor, it's done via special method finalize.


What java interface must be implemented by all threads?

Runnable interface


Can you create an empty interface with no definitions?

Yes. This is a valid interface definition in Java: interface Useless {}


What do mean by interface in java?

An interface in Java is like an abstract class, but there are no method bodies allowed in it and it has to be declared with the interface keyword. It is Java's way of getting around the Deadly Diamond of Death. Only abstract methods and constants are allowed in it.


What is interface in java?

Interface is collection of abstract methods which has only declaration and no implementation


What would interface java be used for?

Interface Java can be used for a variety of tasks and commands such as .swf files, Java files, running scripts, as well as website video players for websites.