From 055043d9e5efe3e92382cde59bf542bb146d9d77 Mon Sep 17 00:00:00 2001 From: Reneta Date: Tue, 30 Oct 2018 14:48:09 +0200 Subject: [PATCH] adding info about interfaces and abstract classes --- guide/english/java/data-abstraction/index.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/guide/english/java/data-abstraction/index.md b/guide/english/java/data-abstraction/index.md index 848733ed029829..8038f34ce214bf 100644 --- a/guide/english/java/data-abstraction/index.md +++ b/guide/english/java/data-abstraction/index.md @@ -9,10 +9,18 @@ Likewise in Object-oriented programming, abstraction is a process of hiding the In Java, abstraction is achieved using Abstract classes and interfaces. +Interface is a piece of code defining a set of operations that other code (classes) must implement. Interfaces were introduced in Java to enhance Java’s single-inheritance model, multiple inheritance created too many problems for programmers and compiler writers. All methods in interface are public, we may not write it every time, like all of them are abstract, but we never write the key word abstract. The interface should have at least one method but not too many. +Abstract classes are classes, which should contain at least one abstract method. Note that we can not create instances from abstract class. +We 'extends' an abstract class and we are obligated to implement all of the abstract methods it contains. + +Abstract class vs. Interface: +All of the methods in one Interface are abstract, while in abstract class we can have methods with body. +We can implement many interfaces, but we can inherit only one abstract class. + Advantages using interfaces: It decouples your code. Helps in team corporation.