Week 11 Flashcards
Jenis polymorphism?
- subtype polymorphism, runtime polymorphism
- parametric polymorphism, compile-time polymorphism
- ad-hoc polymorphism, overloading
perbedaan static dan dynamic binding?
static binding:
- early binding
- pengecekan tipe data variable terjadi saat compile time
dynamic binding:
- late binding
- run time evaluation
pure polymorphism pake jenis binding apa?
dynamic binding
parametric polymorphism pake jenis binding apa?
bisa static atau dynamic
overloading dan overriding pake jenis binding apa?
static binding
syntax pure virtual function? yang tidak memiliki implementasi. class dengan pure virtual function adalah abstract base class
virtual void function() = 0;
standar c++ pake static binding. supaya dynamic pake apa?
virtual keyword
overriding terjadi saat? perlu inheritance
sebuah function dalam base class punya nama, return type, dan parameter yang sama dan ditulis ulang dalam derived class
karakteristik subtype polymorphism?
- butuh inheritance
- static binding / early binding
- compile time
- overriding function
- different scope, different class
karakteristik parametric polymorphism?
- execute same code for any type
2. compile time
ad-hoc polymorphism?
- function with same name, act differently
- overloading function
- no inheritance
- static binding
- compile time
syarat urutan overloading?
- jumlah
- tipe
- urutan
2 jenis virtual function?
- pure virtual function
2. quasi virtual function
ad hoc polymorphism also called as?
overloading
overriding happen only in?
inheritance
when overriding happen?
when a function in the base class, with the same name, same return type, and same parameters is re-written or being overwrite in the derived class.
c++ by default use what type of binding?
static binding
pure virtual method?
only declaring the function prototype / has no implementation. task of function is not defined yet.
contoh:
virtual void function() = 0;
abstract base class?
a class with a pure virtual function
quasi virtual function?
contain a minimal function, usually blank statement, that should be done by the body function. contoh: class myClass{ virtual void function() {;} };
if class contain at least one pure virtual method called?
abstract class
what is interfaces?
classes that contain abstract methods
pure polymorphism?
selection of the appropriate function in a class hierarchy based on the “true” type of the object.
Perbedaan static dan dynamic binding?
static:
- early binding
- compiler resolve the type of a variable at compile time
- based on type, including pointer type
dynamic:
- late binding
- run time evaluation of the “true” type of an object
- default in Java
overloading and overriding is (generally) static binding.
parametric polymorphism is either static or dynamic
pure polymorphism is dynamic binding
apa itu subtype, parametric, dan adhoc polymorphism beserta code nya?
ayo!
Jenis polymorphism yang mengeksekusi code yang sama utk tipe yang berbeda yaitu?
parametric polymorphism