4337 Test 2

¡Supera tus tareas y exámenes ahora con Quizwiz!

old generation

HotSpot JVM does compaction only in what ____ generation.

thread local areas

Small objects are allocated in TLAs. TLA is ___

None of the above

What would it be the result of the following prolog query? ?- p(X, f(Y), a) = p(a, f(b), Y). X=a, Y=f(a). X=f(a), Y=a. X=f(a), Y=f(a). X=a, Y=a.

When the heap becomes full

When is the garbage collected in JVM?

minor garbage collection

When the young generation fills up, this causes ____

eventual collection of the old generation

Which event is called major garbage collection?

Lambda Calculus

Which mathematical subject was utilized for the evaluation of expressions in closures?

Algol

Which of the following programming languages do not use closures?

failure

Negation in Prolog is negation by ____

Name

A(n) _____ is a string of characters used to identify some entity in a program.

P=[parent, jack, mary].

What is the result of the following query? ?- parent(jack, mary) =.. P.

T=[ ].

What would it be the result of T for the following prolog query? ?- [a, b, c] = [X, Y, Z | T].

X=a, Y=[b, c]

What would it be the result of the following prolog query? ?- [a, b, c] = [X | Y].

X=a, Y=b, Z=[c].

What would it be the result of the following prolog query? ?- [a, b, c] = [X, Y | Z].

X=a, Y=a.

What would it be the result of the following prolog query? ?- p(X, f(Y), a) = p(a, f(a), Y).

prefix(P, L) :- append(P, _, L).

As discussed in the class. Select the correct definition of prefix/2 (assuming append/3 provided).

Type

A variable can be characterized by a collection of properties, or attributes, the most important of which is ____.

member(X,S), subset(R,S).

Assume that you have member/2 where member(X, Y) checks whether X is an element of a list Y, complete the first clause of the following Prolog program subset/2 where subset(A, B) will establish a relationship of A being a subset of B. subset([X|R],S) :- subset([ ],_).

First-class functions

Closures are techniques for implementing lexically scoped binding in languages with _____.

Paused

Compaction is performed during garbage collection while all Java threads are:

N>0, A1 is N*A, N1 is N-1, factorial(N1,A1,F).

Complete the second clause of a Prolog program (factorial/3 or factorial(N,A,F)) to compute a factorial F of an integer N, in tail-recursion with an accumulating variable A. factorial(0,F,F). factorial(N,A,F) :- ___________. %% What would it be the body of the prolog rule above?

member(X,R)

Complete the second clause of the following Prolog program for member/2 where member(X, Y) checks whether X is an element (a member) of a list Y. member(X,[X|R]). member(X,[Y|R]) :- ____________.

?- male(P). no

Consider the following bachelor Prolog program. What would it be the "INCORRECT" result of the following query? bachelor(P) :- male(P), not married(P). male(henry). male(tom). married(tom).

A term enclosed in parentheses ( ... ) has precedence of 1000.

Consider the following op(+Precedence, +Type, :Name) where Type is one of {xf, yf, xfx, xfy, yfx, fy, fx}. Which one of the following statements is NOT correct? f indicates the position of the functor. x and y indicate the position of the arguments. y should be interpreted as ''on this position a term with precedence lower or equal to the precedence of the functor should occur''. x should be of the precedence of the argument must be strictly lower than f's. A term enclosed in parentheses ( ... ) has precedence of 1000.

2#3#4 is evaluated in the order of (2 # (3 # 4)).

Consider the following op(+Precedence, +Type, :Name). Which one of the following statements is correct (or resulting in true [or yes])? :- op(500, xfy, #).

Precedence is an integer between 0 and 999.

Consider the following op(+Precedence, +Type, :Name). Which one of the following statements is NOT correct? Name is an operator of type Type with precedence Precedence. Name can also be a list of names. All elements of the list for Name are declared to be identical operators. Precedence is an integer between 0 and 999. Type is one of {xf, yf, xfx, xfy, yfx, fy, fx

Bag = [5, 1, 2, 1, 4]

Consider the following p/3 defined with the query. Which one of the following statements is correct? ?- listing(p). p(1,3,5). p(2,4,1). p(3,5,2). p(4,3,1). p(5,2,4). ?- findall(Z, p(X,Y,Z), Bag).

a

Consider the following parse tree, as discussed in the class. Which one of the following selections is the handle?

It will take an element X out of a list [X|R], resulting in a list R.

Consider the following program xyz/3. Select the result of the query shown below. xyz(X,[X|R],R). xyz(X,[F|R],[F|S]) :- xyz(X,R,S). ?- xyz(X,[1,2,3],L).

A=[3,2,1]

Explain the behavior or goal of the following program (mystery/3). What would it be the result of the query below? mystery(A,B) :- mystery(A,[],B). mystery([X|Y],Z,W) :- mystery(Y,[X|Z],W). mystery([],X,X). ?- mystery([1,2,3], A).

all of the above

For the following Prolog query, X will be ____. ?- X=[ 1 | X ]. a circular list a self-referenced list an infinite list X=[1, 1, 1, ...]

identifier

For variable, the term ____ is often used interchangeably with name.

subset([X|R],S) :- member(X,S), subset(R,S). subset([ ],_).

Given member/2 where member(X, Y) checks whether X is an element of a list Y, Select a Prolog program (subset/2) where subset(A, B) will establish a relationship of A being a subset of B.

union([X|Y],Z,W) :- member(X,Z), union(Y,Z,W). union([X|Y],Z,[X|W]) :- \+ member(X,Z), union(Y,Z,W). union([],Z,Z).

Given member/2 where member(X, Y) checks whether X is an element of a list Y, Select a Prolog program union/3 where union(A, B, C) will establish a "union" relationship where a list C is a union of a list A and a list B.

setjmp and longjmp

In C, _____ functions provide a branch to a location in another function and are useful for handling error conditions with a deeply nested function call.

heap

Java objects reside in the area called ____.

live objects

Major collection is much slower because it involves all _____

Removing unused objects

Memory management is the process of ___. Which one of the following chices is NOT correct? Make space for those new object allocations Removing unused objects Increase RAM Size Allocating new objects virtual memory management

stop the world event

What are all the minor garbage collections called?

Metadata required by the JVM to describe the classes and methods

Permanent generation of the heap contains _____.

unification

What is it called for the variable matching process in Prolog?

N>0, N1 is N-1, factorial(N1,F1), F is N*F1.

Select the body of the second clause of the following Prolog program (factorial/2) to compute a factorial. factorial(0,1). factorial(N,F) :- _____________.

callback

Some C libraries support ____ which is sometimes implemented by providing two values when registering this with the library: a function pointer and a separate void* pointer to arbitrary data of the user's choice.

Mark and Sweep

The JRockit JVM uses _____ model for performing garbage collection

Referencing

The _______ environment binds the non-local names to the corresponding variables in the lexical environment at the time the closure is created.

not(P) :- call(P), !, fail. not(P).

The definition of Prolog negation is ____.

Rss = [1, 4, 9, 16].

What is the result of the following Prolog statements? ?- assert(test(N,R) :- R is N*N). ?- maplist(test,[1,2,3,4],Rss).

Young Generation, Old or Tenured Generation, and Permanent Generation

The heap is broken up into small parts or generations, they are _____

X=f, Y=2

What is the result of the following query? ?- functor(f(a,b), X, Y).

old generation

This generation is used to store long surviving objects.

C++

This programming language _____ enables defining function objects by overloading "operator( )" and also supports closures.

The concept of closure was subsequently adopted and widely used in 1990's, especially with Java, to become widespread.

Which of the following statements is NOT CORRECT about closure? The concept of closures was developed in the 1960s for the mechanical evaluation of expressions in the λ-calculus The concept of closures was first fully implemented in 1970 as a language feature in the PAL programming language to support lexically scoped first-class functions. Peter J. Landin defined the term closure in 1964 as having an environment part and a control part as used by his SECD machine for evaluating expressions. Joel Moses credits Landin with introducing the term closure to refer to a lambda expression. The concept of closure was subsequently adopted and widely used in 1990's, especially with Java, to become widespread.

handle

Which one of the following choices is CORRECT? β is the ___ of the right sentential form γ=αβw if and only if S =>*rm α A w =>rm α β w.

phrase

Which one of the following choices is CORRECT? β is a(n) ___ of the right sentential form γ if and only if S =>* γ = α1 A α2 =>+ α1 β α2

simple phrase

Which one of the following choices is CORRECT? β is a(n) _____ of the right sentential form γ if and only if S =>* γ = α1 A α2 => α1 β α2

Arrays (C++)

Which one of the following choices is not a "closure-like" construct? Select the best answer.

right-sentential

Which one of the following statements is CORRECT? For bottom-up parsing, the parsing problem is finding the correct RHS in a(n) ____ form to reduce to get the previous ____ form in the derivation

Alias may hinder the integrity of the program and correctness in high-level language.

Which one of the following statements is NOT correct?

It is convenient to think of computer memory in terms of physical cells (than in abstraction).

Which one of the following statements is NOT correct?

Names in C++ have no length limit and all characters in them are significant.

Which one of the following statements is NOT correct?

Special words in programming languages tend to be long in length

Which one of the following statements is NOT correct?

The need to remember specific case usage for variable names makes it more precise to write correct programs.

Which one of the following statements is NOT correct?

To some people, "name being case sensitive" is a serious detriment to orthogonality, because names that look very similar in fact denote different entities.

Which one of the following statements is NOT correct?

If the GoalExpression fails with bagof(Things, GoalExpression, Bag), Bag will be the empty list [].

Which one of the following statements is NOT correct? bagof(Things, GoalExpression, Bag) computes all Things which satisfy the GoalExpresssion and collect them in the list Bag. setof(Things, GoalExpression, Bag) computes all Things which satisfy the GoalExpresssion and collect them in the list Bag. findall(Things, GoalExpression, Bag) computes all Things which satisfy the GoalExpresssion and collect them in the list Bag. If the GoalExpression fails with bagof(Things, GoalExpression, Bag), Bag will be the empty list []. findall treats all variables in GoalExpression as if they are existentially quantified.

The clp(FD) solver is available as a library module and loaded with a query :- use_module(library(clp(fd))).

Which one of the following statements is NOT correct? The clp(FD) solver described here is an instance of the general Constraint Logic CLP scheme introduced in [Jaffar & Michaylov 87]. The constraint domain of clp(FD) is particularly useful for modeling discrete optimization and verification problems such as scheduling, planning, packing, timetabling etc. The clp(FD) solver is available as a library module and loaded with a query :- use_module(library(clp(fd))). The solver contains predicates for checking the consistency and entailment of finite domain constraints

binding

Which one of the following statements is NOT correct? A variable can be characterized as a sextuple of attributes which are ___.

termination time

Which one of the following statements is NOT correct? Bindings can take place at ____.

The use of underscores and mixed case in names is a programming design issue as well as a programming style issue.

Which one of the following statements is NOT correct? Consider the name of a variable.

variable

Which one of the following statements is NOT correct? A program ____ is an abstraction of a computer memory cell or collection of cells.

binding

Which one of the following statements is correct? A(n) ____ is an association between an attribute and an entity, such as between a variable and its type or value, or between an operation and a symbol.

link time

Which one of the following statements is correct? A call to a library subprogram in one object file is bound to the subprogram code in the other object file at ____.

language implementation time

Which one of the following statements is correct? A data type, such as int in C, is bound to a range of possible values at ____.

load time

Which one of the following statements is correct? A variable may be bound to a storage cell when the program is loaded into memory at ____.

r-value

Which one of the following statements is correct? A variable's value is sometimes called its ____ because it is what is required when the name of the variable appears in the right side of an assignment statement.

union

Which one of the following statements is correct? Aliases can be created in programs in several different ways. One common way in C and C++ is with their ____ types.

readability

Which one of the following statements is correct? Aliasing is a hindrance to ____ because it allows a variable to have its value changed by an assignment to a different variable.

compile time

Which one of the following statements is correct? At ____, a variable in a Java program is bound to a particular data type.

compile time

Which one of the following statements is correct? Consider the following Java assignment statement: count = count + 5; The type of count is bound at ____.

alias

Which one of the following statements is correct? It is possible to have multiple variables that have the same address by using _____.

language design time

Which one of the following statements is correct? The asterisk symbol (*) is usually bound to the multiplication operation at ___.

run time.

Which one of the following statements is correct? The binding of a variable to a storage cell may not happen until ____ in some cases, as with variables declared in Java methods.

Stack

With a C program (memory map), ____ stores the information that is saved each time a function is called. Each time a function is called, the address of where to return to and certain information about the caller's environment, such as some of the machine registers, are saved on ____.

Initialized Data Segment

With a C program (memory map), _____ contains variables that are specifically initialized in the program.

Text Segment

With a C program (memory map), ______ consists of the machine instructions that the CPU executes.

Heap

With a C program (memory map), ______ is where dynamic memory allocation usually takes place including object instances.

Uninitialized Data Segment

With a C program (memory map), _______, often called the ''bss'' segment, named after an ancient assembler operator that stood for ''block started by symbol.''

Uninitialized Data Segment

With a C program (memory map), data in _____ is initialized by the kernel to arithmetic 0 or null pointers before the program starts executing. The C declaration (for example, "long sum[1000];") appearing outside any function causes this variable to be stored in _____.

size

With a C program (memory map), the _____ command reports the sizes (in bytes) of the text, data, and bss segments.

Stack

With a C program (memory map), the newly called function allocates room on ______ for its automatic and temporary variables for each time it is called. This is how recursive functions in C can work.

Text Segment

With a C program (memory map), usually ______ is sharable so that only a single copy needs to be in memory for frequently executed programs, such as text editors, the C compiler, the shells, and so on.

append([X|Y],Z,[X|W]) :- append(Y,Z,W). append([],X,X).

Write a Prolog program (append/3) where two lists (A and B) are appended, resulting in the third list (C) in 'append(A, B, C)'.

factorial(0,1). factorial(N,F) :- N>0, N1 is N-1, factorial(N1,F1), F is N * F1.

Write a prolog program (factorial/2) to compute a factorial F of an integer N, where factorial of 0 is 1.

all new objects are allocated and aged

Young Generation of the heap is where _____


Conjuntos de estudio relacionados

Hazard Communication Program - PP

View Set

Evidence Based Practice - Quiz questions

View Set

Chapter 30: Assessment and Management of Patients With Vascular Disorders and Problems of Peripheral Circulation

View Set

Chapter 5 - Transfer of Title to Real Property

View Set

Project management final exam prep

View Set

California: Real Estate Principles - Chapter 1

View Set

Chapter 6_NEW! Mini Sim_B2B MARK3300

View Set

Mean, Median, Mode, and Confidence Intervals Sensitivity, specificity, and Predictive Value Standard Curves

View Set

Adult Development and Aging Exam 1

View Set