Week 11 Flashcards

1
Q

Jenis polymorphism?

A
  1. subtype polymorphism, runtime polymorphism
  2. parametric polymorphism, compile-time polymorphism
  3. ad-hoc polymorphism, overloading
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

perbedaan static dan dynamic binding?

A

static binding:

  1. early binding
  2. pengecekan tipe data variable terjadi saat compile time

dynamic binding:

  1. late binding
  2. run time evaluation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

pure polymorphism pake jenis binding apa?

A

dynamic binding

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

parametric polymorphism pake jenis binding apa?

A

bisa static atau dynamic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

overloading dan overriding pake jenis binding apa?

A

static binding

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

syntax pure virtual function? yang tidak memiliki implementasi. class dengan pure virtual function adalah abstract base class

A

virtual void function() = 0;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

standar c++ pake static binding. supaya dynamic pake apa?

A

virtual keyword

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

overriding terjadi saat? perlu inheritance

A

sebuah function dalam base class punya nama, return type, dan parameter yang sama dan ditulis ulang dalam derived class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

karakteristik subtype polymorphism?

A
  1. butuh inheritance
  2. static binding / early binding
  3. compile time
  4. overriding function
  5. different scope, different class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

karakteristik parametric polymorphism?

A
  1. execute same code for any type

2. compile time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

ad-hoc polymorphism?

A
  1. function with same name, act differently
  2. overloading function
  3. no inheritance
  4. static binding
  5. compile time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

syarat urutan overloading?

A
  1. jumlah
  2. tipe
  3. urutan
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

2 jenis virtual function?

A
  1. pure virtual function

2. quasi virtual function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

ad hoc polymorphism also called as?

A

overloading

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

overriding happen only in?

A

inheritance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

when overriding happen?

A

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.

17
Q

c++ by default use what type of binding?

A

static binding

18
Q

pure virtual method?

A

only declaring the function prototype / has no implementation. task of function is not defined yet.

contoh:
virtual void function() = 0;

19
Q

abstract base class?

A

a class with a pure virtual function

20
Q

quasi virtual function?

A
contain a minimal function, usually blank statement, that should be done by the body function. 
contoh:
class myClass{
    virtual void function() {;}
};
21
Q

if class contain at least one pure virtual method called?

A

abstract class

22
Q

what is interfaces?

A

classes that contain abstract methods

23
Q

pure polymorphism?

A

selection of the appropriate function in a class hierarchy based on the “true” type of the object.

24
Q

Perbedaan static dan dynamic binding?

A

static:

  1. early binding
  2. compiler resolve the type of a variable at compile time
  3. based on type, including pointer type

dynamic:

  1. late binding
  2. run time evaluation of the “true” type of an object
  3. default in Java

overloading and overriding is (generally) static binding.
parametric polymorphism is either static or dynamic
pure polymorphism is dynamic binding

25
Q

apa itu subtype, parametric, dan adhoc polymorphism beserta code nya?

A

ayo!

26
Q

Jenis polymorphism yang mengeksekusi code yang sama utk tipe yang berbeda yaitu?

A

parametric polymorphism