ABOUT YOU interview question

Differences of abstract and interface?

Interview Answers

Anonymous

26 Feb 2020

The differences are both theoretical and practical: 1) interface is a description of some capability your class has and advertises (so various classes implementing the same interface can be used the same way) 2) abstract class can be a default implementation, containing the parts which are likely to appear in all the implementations. It doesn't have to implement the complete interface

Anonymous

13 Dec 2018

Abstraction:- Data abstraction refers to, providing only essential information to the outside world and hiding their background details, i.e., to represent the needed information in program without presenting the details. For example, a database system hides certain details of how data is stored and created and maintained. Similar way, C++ classes provides different methods to the outside world without giving internal detail about those methods and data. Interface 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, thereby inheriting the abstract methods of the interface. Along with abstract methods, an interface may also contain constants, default methods, static methods, and nested types. Method bodies exist only for default methods and static methods.