Sunteți pe pagina 1din 6

PLC pra Ujian

Nur Atikah M

1. Language evaluation criteria!

 Readibility : the ease with which programs can be read and understood
 Writability : the ease with which a language can be used to created programs
 Reliability : conformance to specifications (i.e., performs to its specifications)
 Cost : the ultimate total cost

2. Please explain phases in compilation process!

 lexical analysis: converts characters in the source program into lexical units
 syntax analysis: transforms lexical units into parse trees which represent the
syntactic structure of program
 Semantics analysis: generate intermediate code
 code generation: machine code is generated

3. What are the three general methods of implementing a programming language?

 Compilation
- Programs are translated into machine language; includes JIT systems
- Use: Large commercial applications
 Pure Interpretation
- Programs are interpreted by another program known as an interpreter
- Use: Small programs or when efficiency is not an issue
 Hybrid Implementation Systems
- A compromise between compilers and pure interpreters
- Use: Small and medium systems when efficiency is not the first concern

4. What is exception handling?

– Suatu program apabila mengalami kesalahan akan menghasilkan suatu runtime
errors seperti gagal membuka file, suatu program melakukan akses diatas range
array dll.

5. What is the differences between syntax and semantics?

– Syntax: the form or structure of the expressions, statements, and program units
– Semantics: the meaning of the expressions, statements, and program units

6. What is the requirements for a methodology and notation for semantics?

a. Programmers need to know what statements mean
b. Compiler writers must know exactly what language constructs do
c. Correctness proofs would be possible
d. Compiler generators would be possible
e. Designers could detect ambiguities and inconsistencies
7. What is the differences between operational, denotational, and axiomatic
– Operational semantics : Describe the meaning of a program by executing its
statements on a machine, either simulated or actual. The change in the state
of the machine (memory, registers, etc.) defines the meaning of the
– denotational semantics : The process of building a denotational specification
for a language: Define a mathematical object for each language entity, Define
a function that maps instances of the language entities onto instances of the
corresponding mathematical objects.
– axiomatic semantic: Based on formal logic (predicate calculus), Original
purpose: formal program verification,Axioms or inference rules are defined
for each statement type in the language (to allow transformations of logic
expressions into more formal logic expressions), The logic expressions are
called assertions.
8. Distinguish between static and dynamic semantics!
 static: lebih mengarah ke hukum dalam program,analisa semantic yang
terjadi saat compile time
 dynamic: menggambarkan arti dari suatu program dan programmer harus tau
semua yang ia tulis.

9. What is the derivation of “a = b* (c+d)”?

10. What is the potential danger of case-sensitive names?

- Name tidak bisa dibaca walaupun terlihat sama karena hruf besar dan
kecil itu berbeda
11. Define binding and binding time.
- -binding:gabungan antara satu kesatuan dgn sebuah atribut
- -binding time:waktu saat binding terjadi,ada 2 macam:
Early binding: binding saat compile time
Late binding: binding saat run time

12. What are the advantages and disadvantages of dynamic type binding?
– Advantage: fleksibilitas
– Disadvantages:
Biaya yg tinggi
Sultnya meneteksi type error oleh compiler

13. Define lifetime, scope, static scope, and dynamic scope!

- Lifetime:waktu saat variable terikat pada sel memori tertentu
- Scope:kisaran pernyataan dimana itu terlihat
- Static scope: the scope of a variable can be statically determined—that is,
prior to execution.(sebelum eksekusi)
- Dynamic scope: Dynamic scope can be determined only at run time.

14. What are the two common problems with pointers?

- Dangling pointers(pointer terurai) and Lost heap-dynamic
variable(heap dynamic variable yg sudah dialokasikan tdk dapat
diakses user)

15. What is the operand evaluation order?

1. Variables: mengambil nilai dari memori
2. Constants: kadang mengambil nilai dari memori,kadang ambil nilai konstan
dari instruksi bahasa mesin
3. Parenthesized expressions: menghitung semua operator dan operand
terlebih dahulu
4. Kasus yang paling menarik adalah ketika sebuah operan adalah panggilan

16. Distinguish between relational and Boolean expression.

Relational Expressions:
- Menggunakan operator relasional dan operan dari berbagai jenis
- Mengevaluasi bbrp representasi boolean
- Operator symbols menggunakan (!=, /=, ~=, .NE., <>, #)
Boolean Expressions
Operands are Boolean and the result is Boolean
Keadaan dimana expression berhenti dihitung saat hasil sudah didapat.
Dipakai dalam AND dan OR
if (a == b || c == d || e == f)
Jika nilai a==b adalah true,maka sisa expression tidak akan dihitung
karena hasil sudah pasti True
Jika nilai a==b adalah false dan c==d adalah true,maka sisa expression tidak
akan dihitung karena hasil sudah pasti True

Contoh dalam arithmatic exx:

(13 * a) * (b / 13 – 1)
Jika nilai a tidak dideklarasi(a=0),maka nilai otomatis didapat( nilai = 0)
sehingga nilai (b / 13 – 1) tidak perlu dihitung lagi
17. What is short-circuit evaluation?
keadaan dimana expression berhenti dihitung saat hasil sudah didapat
18. How does C support relational and Boolean expressions?
Dengan menggunakan numeric types yang value 0 itu false,1 itu true
19. What is the purpose of a compound assignment operator?
Cara cepat untuk menjalankan suatu assignment
20. What is unusual about C’s multiple-selection statement?
pernyataan C memiliki hampir tidak ada pembatasan penempatan ekspresi kasus.
21. What are the common solutions to the nesting problem for two-way selectors?
menggunakan sarana membentuk pernyataan majemuk bergantian.
22. What are the control structures do you know?
Control statements dan statements dimana eksekusinya dikontrol
23. What are the general characteristics of subprograms?
tiap subprogram punya satu entry point
calling program akan disuspend selama subprogram yang dipanggil
kontrol selalu kembali ke pemanggil ketika subprogram yg dipanggil sudah berakhir
24. What are the differences between a function and a procedure?
Function: mengembalikan nilai
Procedure: langkah yg bisa dieksekusi sesuai urutan
25. What are formal parameters? What are actual parameters?
Formal : Parameter Written In Function Definition
Actual: Parameter Written In Function Call
26. Local variable can be stack dynamic or static. What is the advantages and disadvantages
of dynamic Local variable?
Stack-dynamic :
Advantages Support for recursion
Storage for locals is shared among some subprograms
Disadvantages  Allocation/de-allocation, initialization time
Indirect addressing
Subprograms cannot be history sensitive
Static :
– Advantages and disadvantages are the opposite of those for stack-dynamic
local variables

27. There are 3 semantic models of parameter passing. Please give your explanation.
-In mode: Nilai parameter yang sebenarnya digunakan untuk menginisialisasi
parameter formal yang sesuai
-Out mode: Ketika parameter dilewatkan oleh hasil, tidak ada nilai ditransmisikan ke
-Inout mode: gabungan dari keduanya

28. Define shallow and deep binding for referencing environments of subprograms that
have been passed as parameters.
Shallow binding: The environment of the call statement that enacts the passed
- Most natural for dynamic
Deep binding: The environment of the definition of the passed subprogram
- Most natural for static-scoped languages
29. Define the coroutines!
subprogram yang memiliki beberapa entri dan dapat mengendalikan diri mereka sendiri
• Also called symmetric control: caller and called coroutines are on a more equal basis

• A coroutine call is named a resume

• The first resume of a coroutine is to its beginning, but subsequent calls enter at the
point just after the last executed statement in the coroutine

• Coroutines repeatedly resume each other, possibly forever

• Coroutines provide quasi-concurrent execution of program units (the coroutines);

their execution is interleaved, but not overlapped

30. Define the closures subprogram dan sekitarnya yg direverensi dimana mereka semua
-The referencing environment is needed if the subprogram can be called from any arbitrary
place in the program
-A static-scoped language that does not permit nested subprograms doesn’t need closures
-Closures are only needed if a subprogram can access variables in nesting scopes and it can
be called from anywhere
-To support closures, an implementation may need to provide unlimited extent to some
variables (because a subprogram may access a nonlocal variable that is normally no longer