Signup as a Tutor

As a tutor you can connect with more than a million students and grow your network.

IT Courses/Java

What is use of interface in Java language?

Asked by Last Modified  

Answer
Follow 0

Please enter your answer

16 Answers   0 Likes | 0 DisLikes

I have more than 9 years of experience in Computer teaching

Interface are used to code re-usability, and they are the real driver of ploymorphism in Java. Interface are also allows multiple inheritance in java.

Comments
Dislike Bookmark

interface is mainly used for multiple inheritance which is not available directly in java. Here only methods are named but not defined.

Comments
Dislike Bookmark

It's like forcing to someone implement this task any how .. java does not support multiple inheritance , if i want to force by abstract class and also extends some other class it is not possible , so we can force it by interface we can also implement multiple interfaces at a time , interfaces have abstract methods which must be implemented by extended class .... usually as a team leader of 15 employees i used to create interface to take surety that every class has same method name.

Comments
Dislike Bookmark

Join Urbanpro.com, India’s most trusted education portal for your learning requirements

POST YOUR REQUIREMENT NOW

Interface is used when There only abstract methods in the java interface not method body. It is used to achieve fully abstraction and multiple inheritance in Java.

Comments
Dislike Bookmark

It allows your class to have the functionality of other class without inheriting them. You can implement an interface to provide any specific functionality to your class.

Comments
Dislike Bookmark

Software Development Trainer

Java doesn't support multiple inheritance. Interfaces are a way to do so. Also, for abstraction interfaces are used. For syntactical enforcement also, we use interfaces to make sure every class inheriting the interface, override the methods defined in the interface. For loose coupling also, we use interfaces.

Comments
Dislike Bookmark

As you know that Java does not allow multiple inheritance. Sometime in our real life we need to use multiple inheritance for example an amphibious animal inherits the behaviours of Aquatic and Terrestrial animals together, i.e. can walk on land as well as swim in water. To show the relationships in Java we can use Interface, which allows a class to implement more than one interface at a time. Moreover if we want to make all methods as abstract, we can use interface and provide the freedom to end developer to write own definitions for all methods in the implementing (concrete) class.

Comments
Dislike Bookmark

Experienced Software Professional

It is a contract or behaviour which a class that implements that interface must implement. Another use it that it lets Java programs implement "Multiple inheritance of TYPE" which is the ability to implement more than one interface.

Comments
Dislike Bookmark

Java doesn't support multiple inheritance. In terms of interface you can implement that concept because You would be allowed to implement more than one interfaces in one class

Comments
Dislike Bookmark

Principal Software Engr with good JAVA, J2EE, SQL skills

we can use interfaces for implementing the concept of multiple inheritance..

Comments
Dislike Bookmark
Related Questions

IT Courses/Java

Why we are using this keyword in Java?

Asked by Kiran Bulkquestions 11 Jul

Answer 7
Follow 5
Answer submitted successfully. ×

Please enter your answer

IT Courses/Java

What is the purpose of using throws keyword in java?

Asked by Saritha Bulkquestions 11 Jul

Answer 10
Follow 7
Answer submitted successfully. ×

Please enter your answer

IT Courses/Java

Is synchronized keyword necessary, in Java, if everything that is modified in a function is local to that function?

Asked by Abishiek Bulkquestions 11 Jul

Answer 5
Follow 1
Answer submitted successfully. ×

Please enter your answer

IT Courses/Java

What programming languages should a freshman learn if he already knows C, C++, Java and Python?

Asked by Sushmita Bulkquestions 11 Jul

Answer 7
Follow 4
Answer submitted successfully. ×

Please enter your answer

IT Courses/Java

What is the use of the "this" keyword in Java?

Asked by Deepak Bulkquestions 11 Jul

Answer 9
Follow 6
Answer submitted successfully. ×

Please enter your answer

Looking for a Tutor?

Find best Tutors in your locality on UrbanPro.

FIND NOW

Now ask questions in any of the 1500+ Categories, and Get Answers from Tutors on UrbanPro.com

ASK A QUESTION

Related Lessons

Features Of Java

There is given many features of Java. They are also known as java buzzwords. The Java Features given below are simple and easy to understand. Simple. Object-Oriented. Portable. Platform independent. Secured. Robust. Architecture neutral. Dynamic. Interpreted. High...

JAVA Version History

Java Version History: There are many java versions that has been released. Current stable release of Java is Java SE 8. JDK Alpha and Beta (1995). JDK 1.0 (23rd Jan, 1996). JDK 1.1 (19th Feb, 1997). J2SE 1.2 (8th Dec, 1998). J2SE 1.3 (8th May, 2000). J2SE...

History Of Java

Java history is interesting to know. The history of java starts from Green Team. Java team members (also known as Green Team), initiated a revolutionary task to develop a language for digital devices such as set-top boxes, televisions etc. For the green...

10 Cool SQL Optimizations That Do Not Depend On The Cost Model

Today, we don’t want to talk about cost based optimisation, i.e. optimisations that depend on a database’s cost model. We’ll look into much simpler optimisations that can be implemented purely based on meta data (e.g. constraints) and...

jOOQ 3.10 Supports JPA Attribute Converter

One of the cooler hidden features in jOOQ is the JPADatabase, which allows for reverse engineering a pre-existing set of JPA-annotated entities to generate jOOQ code. For instance, you could write these entities here: @Entity public class Actor { ...

Sponsored

Find Best Java Training Classes?

Find Now »