answersLogoWhite

0

Interface is used in java but not in C why?

Updated: 8/16/2019
User Avatar

Wiki User

16y ago

Best Answer

The short answer: because C is not object-oriented.

The reason for C++ not having interfaces is, that C++ supports multiple inheritance. Because C++ classes can be derived from more than one base class, so there is no need to have interfaces.

In Java, each class has exactly one base class (except the class Object). With the help of interfaces it is possible implement a restricted (and more stable) form of multiple inheritance.

Interfaces follow implicitly the following rules:

* interfaces are abstract

* each method is public abstract

* each attribute is public static final

User Avatar

Wiki User

16y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Interface is used in java but not in C why?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

In C plus plus Interface is also known as?

I guess you mean Java, there is no interface in C++.


What is JNI?

Java Native Interface JNI is an interface between java and applications and libraries written in other languages. As an example, JNI enables Java programs to use C libraries and also enables C programs to use Java classes.


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.


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.


Purpose of marker interface in java?

Generally, they are used to give additional information about the behaviour of a class.It is just used to "mark" Java classes which support a certain capability . Examples: java.util.RandomAccess java.io.Serializable java.rmi.Remote java.util.EventListner javax.servlet.SingleThreadModel java.lang.Clonable javax.ejb.EnterpriseBean


Which languages support multiple interface?

If by interface you mean, a mechanism to achieve abstraction and create a blueprint for future implementation. Java/C#/C++ all allow for multiple interfaces(abstract classes in C++) to be implemented.


Program for length of list in java?

Java's List interface defines the size() method, which can be used to retrieve the length of a list.


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.


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