Programing Lang

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

2 bytes can represent 27485 decimal data type, using packed BCD. (True/False)

False

A top-down parser processes a parse tree in post-order. (True/False)

False

After a sequence of derivations, the following sentential form is produced. This is an example of a right-sentential form: <expr> --> a + b * <term> - <factor> (True/False)

False

All the real numbers can be represented precisely using floating point data types. (True/False)

False

C and C++ require a compile-time descriptor instead of a run-time descriptor (True/False)

False

Characteristics of readability are the same as those of writability. (True/False)

False

Context-free grammars were initially developed to describe programming languages. They were later used to describe natural languages such as English. (True/False)

False

Dynamic Binding occurs at compile time and stays unchanged throughout program execution. (True/False)

False

In a dynamic length string, the string length is fixed when the string is created. (True/False)

False

One of the approaches to building a parser vs. a lexical analyzer is use of a state diagram. (True/False)

False

Strings are primitive types in all programming languages. (True/False)

False

The Descriptor of a variable contains the list of all the variables declared in a program. (True/False)

False

The integer literal 368 is a data type, which refers to all whole numbers on a computer. (True/False)

False

The term variable refers to only a name which identifies a memory cell or collection of cells. (True/False)

False

When a parser encounters an error, it produces an error message and terminates parsing. (True/False)

False

A --> <B> + C is a valid BNF rule.

False A is a terminal symbol and does not have a production rule

A grammar is ambiguous if and only if it generates a sentence that has two or more distinct parse trees (True/False)

True

An example of binding is association between a variable named counter, and its type, int. (True/False)

True

Associativity rules are used to express precedence among arithmetic operators. (True/False)

True

BNF can be used to specify the grammar of a programming language (True/False)

True

Binding of an entity such a variable to an attribute such as its type can happen during compile time. (True/False)

True

Consider the sentence "aba" and the following grammar. Is the grammar ambiguous? (Justify it for yourself!) <A> --> <A> a <A> --> a <A> <A> --> b (True/False)

True

Dynamic length strings are usually more costly in terms of efficiency and memory than the static length strings. (True/False)

True

Given a sentence and a grammar, a top-down parser starts with the grammar's start symbol and tries to reach the given sentence. (True/False)

True

In an arithmetic expression, an operator, which is generated lower in the parse tree indicate that it has precedence over an operator produced higher up in the tree. (True/False)

True

In recursive-descent parsing, there is a subprogram for each nonterminal in the grammar (True/False)

True

Integer data types represent a set of whole numbers (vs. decimal numbers) and corresponding operations. (True/False)

True

Orthogonality is one of the characteristics contributing to the readability of a language. Orthogonality refers to having a small number of primitive constructs, which can be combined in a small number of ways to build the structures of a language. (True/False)

True

The Descriptor of a static variable is created during the compilation process. (True/False)

True

The address attribute of a variable refers to the memory address to which the variable is associated with. (True/False)

True

The following code correctly parses a sentence generated by the rule: <A> --> <B> (* | /) <C> void A() { B(); if (nextToken == MULT_OP || nextToken == DIV_OP) { lex(); C(); } } (True/False)

True

The following rule states that in an arithmetic expression, the "+" operator is evaluated from left to right. <term> → <term> + <factor> (True/False)

True

Type checking facilitates error detection. (True/False)

True

Use of a Boolean data type (e.g., Boolean finished = true) instead of an integer data type (e.g., integer finished = 1) in defining variables, which can store only one of two values usually help the readability of a program. (True/False)

True

User defined data types improve readability of a program. (True/False)

True

User-defined operator overloading may harm the readability of a program? (True/False)

True

Von Neumann computer architecture was the basis of design of imperative languages (True/False)

True

Which statement below is correct? (select all that apply) a) A computer's CPU is faster than its main memory b) Interpreter allows for easier implementation of programs c) Compiled programs require less space than interpreted programs d) Compiled programs execute faster than the interpreted programs

a) A computer's CPU is faster than its main memory b) Interpreter allows for easier implementation of programs c) Compiled programs require less space than interpreted programs d) Compiled programs execute faster than the interpreted programs

What are lexical and syntax analyzers usually used for? (Select all that apply) a) As an application of grammars b) Compiler design c) Program formatters d) Interpreter design

a) As an application of grammars b) Compiler design c) Program formatters d) Interpreter design

Type checking in a programming language can be done during: (select all that apply) a) Compilation b) Execution

a) Compilation b) Execution

Select all the correct statements. a) Compilers often base the semantics of language structures on their syntactic form b) Compiler chooses the code to be generated for a statement by examining its parse tree c) Compilers base the syntax of language on their semantic structures d) If a language structure has more than one parse tree then the meaning of the structure cannot be determined uniquely

a) Compilers often base the semantics of language structures on their syntactic form b) Compiler chooses the code to be generated for a statement by examining its parse tree d) If a language structure has more than one parse tree then the meaning of the structure cannot be determined uniquely

Some examples of programming language categories are (select all that apply) a) Imperative b) Declarative c) Logic

a) Imperative b) Declarative c) Logic

Users of a language definition are (Select all that apply) a) Implementers of the language b) Other language designers c) Programmers d) Compiler and interpreter creators

a) Implementers of the language b) Other language designers c) Programmers d) Compiler and interpreter creators

The study of programming languages is valuable for a number of reasons: (select all that apply) a) Increase our capacity to use different constructs b) Enable us to choose languages more intelligently c) Makes learning new languages easier

a) Increase our capacity to use different constructs b) Enable us to choose languages more intelligently c) Makes learning new languages easier

Some reasons for studying concepts of programming languages are (select all that apply) a) Increased ability to learn new languages b) Producing reports using decimal numbers and characters c) Better use of languages that are already known

a) Increased ability to learn new languages c) Better use of languages that are already known

The task of analyzing syntax is separated into the following parts (Select all that apply) a) Lexical analysis b) Syntax analysis c) Parsing

a) Lexical analysis b) Syntax analysis c) Parsing

Which statement is correct? (Select all that apply) a) Parse tree is a hierarchical representation of a derivation b) Every internal node of a parse tree is labeled with a nonterminal symbol c) Every leaf is labeled with a terminal symbol d) The root of a parse tree is labeled with a nonterminal symbol

a) Parse tree is a hierarchical representation of a derivation b) Every internal node of a parse tree is labeled with a nonterminal symbol c) Every leaf is labeled with a terminal symbol d) The root of a parse tree is labeled with a nonterminal symbol

Some programming language methodologies are (select all that apply) a) Procedure-oriented b) Object-oriented c) Data-oriented

a) Procedure-oriented b) Object-oriented c) Data-oriented

In the fetch-execute-cycle (on a Von Neumann architecture computer) (select all that apply) a) Program counter is initialized before the cycle starts b) Program counter is incremented after each fetch operation c) Program counter may be changed during the decode operation d) Program counter may be changed as a result of the execute operation

a) Program counter is initialized before the cycle starts c) Program counter may be changed during the decode operation d) Program counter may be changed as a result of the execute operation

The statement "if (Boolean_expr) statement" (Select all that apply) a) Shows the syntax of the if-statement b) Implies the semantics of if-statement

a) Shows the syntax of the if-statement b) Implies the semantics of if-statement

A language implementer usually uses any of the following approaches to represent dynamic-length strings in memory. (select the correct answers) a) Store characters of the string in adjacent storage cells. b) Use arrays of pointers to individual characters of the string. c) Use a linked list of characters. d) Use a variable for each character of the string

a) Store characters of the string in adjacent storage cells. b) Use arrays of pointers to individual characters of the string. c) Use a linked list of characters.

Which statement is correct? a) Syntax analyzer receives a token from the lexical analyzer b) Lexical analyzer receives a token from the Syntax analyzer c) Lexical analyzer is the portable component of a compiler

a) Syntax analyzer receives a token from the lexical analyzer

Given the statement, average = (num1 + num2) / 2 What does each lexical unit represent? (Select all correct representations) a) average is a lexeme b) left_paren is a token c) ( is a lexeme d) equal_sign is a lexeme

a) average is a lexeme b) left_paren is a token c) ( is a lexeme

Given the following grammar, which sentential form can be generated from it in a leftmost derivation? <assign> is the start symbol. <assign> → <id> = <expr> <id> → A | B | C <expr> → <id> + <expr> | <id> * <expr> | ( <expr> ) | <id> (select all correct ones) a) A b) A = A c) <assign> d) A = B + D

b) A = A c) <assign>

Which statement below is NOT correct? a) A sentential form is a string of terminal and/or non-terminal symbols derived from the start symbol b) A sentence is a sentential form that contains only nonterminals c) A leftmost derivation is one in which the leftmost nonterminal in each sentential form is expanded

b) A sentence is a sentential form that contains only nonterminals

The following characteristics increase reliability of a program: (select all that apply) a) Aliasing b) Exception Handling c) Compile-time type checking d) Run-time type checking

b) Exception Handling c) Compile-time type checking d) Run-time type checking

Which EBNF rule is equivalent to the following BNF rule? <term> → <term> + <factor> | <term> - <factor> (Select all that apply) a) <term> → <term> {+ | -} <factor> b) <term> → <term> {- | +} <factor c) <term> → <term> (+ | -) <factor> d) <term> → <term> (- | +) <factor>

c) <term> → <term> (+ | -) <factor> d) <term> → <term> (- | +) <factor>

The following pattern matches a string which consists of/​[A-Z\d]+/ a) A sequence of one or more digits b) A sequence of one or more upper-case letters c) A sequence of one or more digits and upper-case letters d) A sequence of one or more letters and digits

c) A sequence of one or more digits and upper-case letters

The following help achieve simplicity in a language: a) A large number of basic constructs b) Multiple ways of performing a particular operation c) Minimal operator overloading

c) Minimal operator overloading

Which definition is correct? a) Lexical analyzer converts source code into machine code b) Syntax analyzer converts lexical units into individual characters c) Code generator produces the source code d) Syntax analyzer transforms lexical units of a program into syntactic structure of the program

d) Syntax analyzer transforms lexical units of a program into syntactic structure of the program


Set pelajaran terkait

Algebra Lesson 4.7 "absolute value inequalities"

View Set

Saunders NCLEX-RN Leadership Management Delegating & Prioritizing

View Set

Negotiable Instruments and Credit

View Set

Chapter 7, part2-Social Security Benefits and Taxation

View Set

Chapter 1: Environment and Theoretical Structure of Financial Accounting

View Set

Biological psychology Practice Quiz's clo 1

View Set

INTEGRATION PRACTICE QUESTIONS FOR FINAL # 1 IDOLIS

View Set

Concepts Review & Self Study CH 6

View Set

The Cosmic Perspective Fundamentals 2e: CH. 1-11, 12.3, 13.2, 14.1, 14.3

View Set