oop - Can anyone broadly explain abstract class and interface? -


can broadly explain abstract class , interface? know theoretically think it's not enough implementation. saw lot of tutorials on seems me without abstract class can job, why need use abstract class. actually, want know use of abstract , interface , how it'll helpful.

understanding these 2 mechanisms in programming tough 1 teach because on paper share lot of similarities, , in code more depending on language. question have asked throw many duplicate references because question gets asked lot. focus in on premise asking i'll see if can add bit more context.

interfaces

a way of declaring common related properties , methods between classes. class definitions can inherit many of these, , down each class declares inheritance of said interface implement members , methods.

abstract classes

similar interfaces, abstract classes declare common related properties , methods, class may inherit 1 abstract class, 1 of main defining characteristic (and obvious) differences between two. because of characteristic hear abstract classes referred base class (although class can base class long not sealed or final). other language dependent differences include being able define static, instanced, protected , virtual (can overridden) methods.

so can see both of these mechanisms have uses , each has other not. means there times when 1 relevant when other not, , times when both needed in tandem.

koda


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -