i) Which kind of variable has the longest lifetime? a) An implicitly heap- dynam
ID: 3547994 • Letter: I
Question
i) Which kind of variable has the longest lifetime?
a) An implicitly heap- dynamic variable
b) A static variable
c)A stack-dynamic variable
d)A flexible-length variable
e) A flixed-length variable
f) A lexically scoped variable
ii) Which of the following is true of aliases?
a) An alias changes the name of something
b) An alias protects an existing value from being overwritten
c) An alias provides an alternative way of accessing something
d) An alias allows type inference
iii) Which of the following is the strictest, as applied to record types?
a) name equivalence
b) structural equivalence
c) subtype agreement
d) assignment compatibility
iv) What happens in an assignment such as "x:=y"?
a) The address of x is modified to be the address of y
b) The address of y is modified to be the address of x
c) The object bound to y is copied and bound to x, and any previous binding of x to an object is lost
d) x and y become aliases
Explanation / Answer
i) a
here is quick lifetime of all variable types:
static variable (global scope)
lifetime = program runtime (1)
visibility = the compilation unit it is instantiated in (2)
heap variable
lifetime = defined by you (new to delete)
visibility = defined by you (whatever you assign the pointer to)
stack variable
visibility = from declaration until scope is exited
lifetime = from declaration until declaring scope is exited
ii) c
iii) a
iv) c
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.