123ArticleOnline Logo
Welcome to 123ArticleOnline.com!
ALL >> Education >> View Article

Using Interface We Get The Multiple Interface In Java

Profile Picture
By Author: infocampus
Total Articles: 33
Comment this article
Facebook ShareTwitter ShareGoogle+ ShareTwitter Share

Introduction :
An interface is a reference type in Java. It is similar to class. It is a collection of abstract methods. A class implements an interface, hence inheriting the abstract methods of the interface.
With abstract methods , an interface contain constants, default methods, static methods, and nested types. An interface contains behaviors that a class implements.
Unless the class that implements the interface is abstract, all the methods of the interface need to be defined in the class.
How interface is similar to a class ?
An interface is similar to a class in the following ways −
1) An interface can contain any number of methods.
2) An interface is written in a file with a .java extension, with the name of the interface matching the name of the file. java training center bangalore
3) The byte code of an interface appears in a .class file.
4) Interfaces appear in packages, and their corresponding bytecode file must be in a directory structure that matches the package name.
How interface is different from the class ?
An interface is different from ...
... a class in following ways −
1)We cannot create the object of an interface.
2)An interface does not contain any constructors.
3)All of the methods in an interface are by default abstract .
4)An interface cannot contain instance fields. The only fields that can appear in an interface must be declared both static and final. java course in bangalore
5)An interface is not extended by a class; it is implemented by a class.
6)An interface can extend multiple interfaces.
Declaration of Interface :
The interface keyword is used to declare an interface.
Implementing Interfaces :
When a class implements an interface, all methods of the interface should be implemented by the class . Otherwise declare the class as abstract .A class uses the implements keyword to implement an interface.
Extending Interfaces :
An interface can extend another interface in the same way that a class can extend another class. The extends keyword is used to extend an interface, and the child interface inherits the methods of the parent interface. advanced java training in bangalore
Extending Multiple Interfaces :
A Java class can only extend one parent class. Multiple inheritance is not allowed using class . Interfaces are not classes, however, and an interface can extend more than one parent interface. So multiple inheritance is possible using interface .
The extends keyword is used once, and the parent interfaces are declared in a comma-separated list.
Tagging Interfaces :
The most common use of extending interfaces occurs when the parent interface does not contain any methods.
An interface with no methods is known as a tagging interface. There are two reason for tagging interfaces – best core java training in bangalore
Creates a common parent − As with the EventListener interface, which is extended by dozens of other interfaces in the Java API, we can use a tagging interface to create a common parent among a group of interfaces. For example, when an interface extends EventListener, the JVM knows that this particular interface is going to be used in an event delegation scenario.
Adds a data type to a class − This situation is where the term, tagging comes from. A class that implements a tagging interface does not need to define any methods (since the interface does not have any), but the class becomes an interface type through polymorphism. Java/j2ee classes bangalore
Why we use interface ?
Interface is mainly used for abstraction. Since methods in interfaces do not have body, they have to be implemented by the class before we can access them. The class that implements interface must implement all the methods of that interface. Also, java programming language does not support multiple inheritance using class , using interfaces we can achieve this .
Some important points for interface :
1.interface is the keyword that is used to create an interface in java.
2.We can’t create object for an interface in java.
3.Interface contains only abstract methods. Java training center bangalore
4.Interfaces can’t have constructors
5.By default any attribute of interface is public, static and final
6.An interface can’t extend any class but it can extend another interface..
7.implements keyword is used by classes to implement an interface.
8.A class implementing an interface must provide implementation for all of its method unless it’s an abstract class.
This is the short description about the interface . To get the good knowledge on java for getting a job as java developer attend java training in Infocampus Software Training Institute .
Author : Infocampus is the best java training center bangalore . It provides java course with the 100% placement assistance and live project .Free demo classes are available for java/j2ee classes . For best core java training complete practical classes are provided by the infocampus . Every weekend demo classes are available for advanced java training . In java training syllabus is according to getting a job easily .
To book the seat for free demo class on java training call at : 9738001024 or to get the syllabus of java course enquire at : http://www.infocampus.co.in/java-training-bangalore.html

Total Views: 257Word Count: 831See All articles From Author

Add Comment

Education Articles

1. Ff Academia - Acca Classes In Kerala
Author: Michael Oliver

2. Sof Olympiad Nso & Imo Online Classroom Course
Author: MTG Books

3. How To Study At Home For Mppsc Exam?
Author: jyiti makhija

4. Are You Looking For The Best Ias Coaching In Indore?
Author: sweeti sharma

5. What Is The Need Of Best Upsc Coaching In Indore?
Author: lavya singh

6. Best Engineering Colleges In India
Author: Campushunt

7. How To Write A Descriptive Essay
Author: Ethan Taylor

8. 4 Tips To Have Financial Freedom As A Student
Author: annepgill

9. Arvind Mafatlal Group Announces Foray Into Education Technology & Service
Author: Harish Babu

10. How Pgdm Teaching Methods Will Change Post Covid
Author: Anish

11. Master The Skills To Sustain In The Corporate World With Pgdm
Author: Weschool

12. Defensive Driving Online Classes For Fresher And Beginners
Author: NBK All Risk Solutions

13. Why It Is Better To Study In The Private Engineering College?
Author: aryaninstitute

14. Advance The Career Easily With The Best Engineering Program
Author: aryaninstitute

15. Top 5 College Of Andhra Pradesh
Author: Aviansh Kumar

Login To Account
Login Email:
Forgot Password?
New User?
Sign Up Newsletter
Email Address: