146 Programming Language Q&A (P5)

Programming Language Concepts

Back at it again. This time we’ll cover some common questions/answers you may encounter when asked about:

  • Names, Bindings and Scopes
  • Data Types

401. Names are also called _______.

– Identifiers

402. Why are names also called identifiers?

– Because they are used to identify a variable, a function, class or other program constructs.

403. Fortran I names had a maximum name length of _____.

– Six

404. COBOL names had a maximum length of ______.

– 30

405. Name two languages that don’t have a name length limit.

– Java and C#

406. How are scalar, arrays and hash names defined in Perl?

– $, @ and %

407. What do the @ and @@ symbols represent in Ruby?

– Class Instance and Class Object

408. What is a keyword?

– A word that’s special only in certain context

409. What is a reserved word?

– A special word that cannot be used as a user-defined name.

410. True or False? Keywords can be overwritten by user-defined names.

– True

411. What is a variable?

– An abstraction of memory

412. What does the address variable characteristic represent?

– The memory address with which the variable is associated with

413. What does the following variable characteristic represent: value?

– The contents of the location with which the variable is associated.

414. True or false? A variable may have different addresses at different times during execution.

– True

415. If two variable names can be used to access the same memory location, they are called _______.

– aliases

416. How are aliases created?

– Pointers and reference variables

417. What does the variable’s type determine?

– The range of values of the variable
– The set of operations for that type
– The precision

418. What is an abstract memory cell?

– Way of thinking about the physical cell or collection of cells associated with a variable

419. A ________ is an association, such as between an attribute and an entity, or between an operation and a symbol.

– binding

420. The ______ ______ is the time at which a binding takes place.

– binding time

421. Describe what takes place during the language design time.

– Program structure (syntax)
– Primitive types and meanings (semantics)
– i.e. binding of * to the multiplication operator

422. Describe what takes place during the language implementation time.

– Coupling of I/O to OS
– Maximum sizes of stack of heap
– Precision of fundamental types
– i.e. binding of floating type to an internal representation in C

423. Describe what takes place during the compile time.

– Map high-level language constructs to machine code.
– i.e. binding of a variable to a particular type in C or Java

424. Describe what takes place during the link time

– Multiple object codes (machine code files) and libraries are combined into one executable
– i.e. binding a library subprogram to subprogram’s code

425. Describe what takes place during load time.

– OS loads the executable in memory
– Assign machine addresses to static data
– i.e. binding of a C static variable to a memory cell

426. Describe what takes place during run time.

– The time during which a program runs
– i.e. bindings of non-static variables in a subprogram to a memory cell.

427. A binding is ______ if it first occurs before run time and remains unchanged throughout program execution.

– static

428. A binding is ______ if it first occurs during execution or can change during execution of the program.

– dynamic

429. Before a variable can be referenced in a program, it must be bound to a ____ _____.

– data type

430. Give an example of an explicitly declared static type binding.

– int i;

431. Give an example of an implicitly declared static type binding.

– Fortran: I, J, K, L, M, N implicitly declare to be integer type.

432. True or False? Type inference is a way to implicitly declare a binding.

– true (i.e. var sum = 0; or var total = 0.0;)

433. True or False? Dynamic Type Binding uses declarations.

– False

434. Give an example of dynamic type binding.

– apple = “Apple”;
apple = 17.3;

435. What is allocation?

– The binding of a variable to a memory cell that is taken from a pool of available memory.

436. What is deallocation?

– the process of unbinding a variable and placing the memory cell back in the pool of available memory.

437. What is the lifetime of a variable?

– The time during which the variable is bound to a specific memory location.

438. What are the four categories of variables by lifetime?

– Static, stack-dynamic, explicit heap-dynamic and implicit heap-dynamic

439. What are the 3 main areas in memory that are allocated for variables?

– Static area, stack and heap

440. True or False? Static variables are bound to memory cells before program execution begins and remain bound to those same memory cells until termination.

– True

441. What is the lifetime of a static variable?

– Entire program execution

442. Static variables can be used as global variables and ____ _____ variables.

– history sensitive

443. True or False? In early Fortran, all variables were static.

– True

444. True or False? In C and C++, global variables are always static.

– True

445. Describe what is meant by a history sensitive variable.

– local variables that are declared static

446. True or False? A program that has only static variables can support recursive subprograms.

– False

447. In stack-dynamic variables, the type is ______ bound.

– statically

448. In stack-dynamic variables, the storage is bound when their declarations are _______.

– elaborated

449. What is meant by elaboration in declarations?

– the storage allocation and binding process that takes place when the code containing the declaration is executed.

450. Stack dynamic variables are allocated from the _____ _____ _____.

– run time stack

451. True or False? Programming languages that allow stack-dynamic variables allow recursion.

– True

452. For stack-dynamic variables the size of local variables is determined at _____ time.

– run

453. True or False? Stack-dynamic variables are history sensitive.

– False

454. What is the heap?

– Unstructured pool of memory cells

455. What is the lifetime of explicit heap-dynamic variables?

– from explicit allocation to explicit deallocation

456. The explicit heap-dynamic variables can only be accessed through ________ or ______ variables.

– pointer or reference

457. Explicit heap-dynamic variables are created either by an _______ or a call to a ______ _______.

– operator (new in C++) or library function (malloc in C)

458. Objects in Java are ______ heap-dynamic and are accessed through _______ variables.

– explicit
– reference

459. Java relies on ______ _______ to destroy a heap-dynamic variable.

– garbage collection

460. In C#, explicit heap-dynamic and stack-dynamic objects are _______ deallocated.

– implicitly

461. When are implicit heap-dynamic variables bound to heap storage?

– when they are assigned values

462. What is the lifetime of implicit heap-dynamic variables?

– from implicit allocation to implicit deallocation

463. What is the scope of a variable?

– the range of the statements in which the variable is visible

464. A variable is _____ if it can be referenced.

– visible

465. What is a local variable?

– a variable declared in a program unit (subprogram) or block.

466. What is a nonlocal variable?

– a variable visible in a program unit or block, but not declared there.

467. What is a global variable?

– a special category of nonlocal variables

468. What is static scoping?

– the scope of a variable can be determined prior to execution at compile time

469. What is dynamic scoping?

– the score of a variable is determined at run time.

470. Static scope is sometimes referred to as _____ ______.

– lexical scope

471. True or False? In languages that use static scoping, variable declarations can be hidden.

– True

472. Variables within a block are typically _____ _______.

– stack dynamic

473. In python, a global variable can be referenced in a function, but it can be modified there only if the function has declared it to be _____.

– global

474. True or False? Dynamic scope is based on the order in which subprograms are called, not their nesting.

– True

475. True or False? Scope and Lifetime are different concepts?

– True

476. What is the referencing environment of a statement?

– the collection of all names that are visible in the statement.

477. What is an active subprogram?

– Execution of the subprogram has begun and is not yet terminated.

478. What is a named constant?

– A variable that is bound to the same value throughout its lifetime

479. True or False? The binding of values to named constants can only be static.

– False. It can be static or dynamic

480. The binding of a variable to a value at the time it is bound to storage is called _______.

– initialization

481. What does a data type define?

– A collection of values and a set of operations on those values.

482. True or False? In the early languages, all data structures had to be simulated with arrays.


483. ______ _______ ______ were one of the most important advances and paved the way for abstract data types, classes, and object-orientation.

– User-defined types

484. Data types are either _____ or ______ (scalar).

– structured or unstructured

485. What is a variable descriptor?

– The collection of attributes of a variable

486. What are descriptors used for?

– Type checking and allocation and deallocation operations.

487. Data types that are not defined in terms of other types are called _____ ____ _____.

– primitive data types

488. ______ is the most common primitive numeric type

– Integer

489. What are the four signed integer types provided by Java?

– byte, short, int and long

490. True or False? C++ and C# have unsigned integer types.

– True

491. What are the three ways to store negative integers?

– Sing magnitude notation, two’s complement notation, and one’s complement notation

492. What are the two floating-point types included in most Programming Languages?

– float and double

493. Most larger computers that are designed to support business applications have hardware support for the _____ data types.

– decimal

494. True or False? C89 has a Boolean type

– False

495. How is the Boolean type represented in C89

– nonzero numbers are true and zero is false

496. True or False? C99 and C++ have a Boolean type

– True

497. True or False? The Boolean type is stored in one bit.

– False, one byte since the byte is the lowest retrievable storage unit.

498. _____ was the first widely used language to use the Unicode character set.

– Java

499. True or False? Python has a character type.

– False, instead characters are treated as strings of length 1

500. Name a few of the most common string operations.

– Assignment, Concatenation, Substring Reference, comparison, and pattern matching

501. How are character strings stored in C and C++?

– char arrays

502. How do you mark the end of a string in C?

– With the null character

503. In Java, strings are supported by two classes: _____ and ______.

– String and StringBuffer

504. True or False? Java’s String class is mutable.

– False. StringBuffer is mutable.

505. True or False? In Python, string is a primitive type and strings are immutable.

– True

506. Pattern matching in Perl, JavaScript, Ruby and PHP is based on _______ ________.

– regular expressions

507. What is a static-length string?

– the length of a string is fixed (i.e. Java’s String object)

508. What is a limited dynamic-length string?

– the length of a string can vary up to a declared and fixed maximum set by the variable’s definition.

509. What is a dynamic-length string?

– the length of a string can vary with no maximum

510. What is an enumeration type?

– specifies all possible values of the type by providing a list of enumeration constants.

511. ____ and ______ were the first widely used languages to include an enumeration data type.

– C and Pascal

512. Is the following example a legal operation on this C++ enumeration type? myColor=4;

– No, but casting would make it legal (i.e. myColor=(colors) 4;

513. True or False? In Java, enumeration constants are instances of the class.

– True

514. A Java enumeration is implicitly a ______ of the Enum class.

– subclass

515. True or False? A Java enumeration inherits methods from the Enum class.

– True

516. What does the ordinal method do?

– Returns the numeric value of an enumeration object.

517. True or False? PHP and JavaScript inherit from the Enum class.

– False, PHP and JavaScript do not have enumeration types at all.

518. What are the two properties of an array data structure?

– All elements have the same type
– Elements are accessed by position relative to the first element

519. References to an array element are specified using __________ ___________.

– subscript expressions

520. How are array elements accessed?

– by giving the name of the array and a selector that specifies the position of the element

521. The position of an element is specified by ________ or ___________.

– subscripts or indices

522. What are the two distinct types involved in an array type?

– element type and type of the subscripts

523. The type of the subscript is often _______.

– integer

524. In Perl, array names should begin with _____ but the _____ is used when accessing an element in an array.

– @
– $

525. True or False? Negative subscripts are allowed in Perl.

– True

526. A reference to a nonexistent array element in Perl yields _____.

– undef

527. The binding of the subscript type to an array variable is usually ______.

– static

528. True or False? The lower bound of the subscript range is often implicit.

– true

529. What are the five categories that arrays can be divided into?

– Static, Fixed stack-dynamic, stack-dynamic, fixed-heap dynamic and heap-dynamic

530. What is a static array?

– when subscript ranges are statically bound and storage allocation is static

531. Arrays declared in C & C++ functions that include the _____ modifier are static.

– static

532. What is a fixed stack-dynamic array?

– Subscript ranges are statically bound but the allocation is done at declaration time. Use a static modifier and a fixed size.

533. What is a stack-dynamic array?

– Subscript ranges are dynamically bound, and the storage is dynamically allocated.

534. What is a fixed heap-dynamic array?

– Subscript ranges are dynamically bound, and the storage allocation is dynamic, but they are both fixed after storage is allocated. Storage is allocated on the heap. i.e. malloc and free in C or new in C++

535. True or False? In Java all arrays are fixed heap dynamic arrays.

– True, once created they keep the same subscript ranges and storage

536. What is a heap-dynamic array?

– subscript ranges are dynamically bound, and the storage allocation is dynamic, and can change any number of times during the array’s lifetime. i.e. C#’s ArrayList class or JavaScript arrays

537. A reference to a nonexistent element in a JavaScript array yields _______.

– undefined

538. Arrays of string can be initialized by a list of _____ ______.

– string literals

539. True or False? When an initializer is present, the length of the array can be omitted.

– True

540. True or False? An array operation is performed on a single array element.

– False, it’s performed on an entire array.

541. A true multidimensional array is called a _________ __________.

– rectangular array

542. What is a jagged array?

– Lengths of rows are not the same

543. True or False? Java supports rectangular arrays

– False, only jagged arrays

544. True or False? Multidimensional arrays must be mapped onto the linear structure of the computer memory.

– True

545. What are the two common ways to map multidimensional arrays onto the linear structure of the computer memory?

– Row-major order and column-major order

546. What is the access function of a one-dimensional array?

– address(list[k]) = address(list[0]) + k * element_size

Want more?

P1. 104 Programming Language Q&A
P2. 95 Programming Language Q&A
P3. 123 Programming Language Q&A
P4. 77 Programming Language Q&A
P5. 146 Programming Language Q&A
P6. 94 Programming Language Q&A
P7. 141 Programming Language Q&A


Leave a Reply