CSCI 333 Programming Languages
self.x
Within a class's method definition, the instance variable x could be accessed via which expression?
Functional paradigm
The _______ is a programming paradigm based on the mathematical notion of calculus.
object-oriented
The _____________ programming paradigm allows the reuse of large pieces of code.
float
The data type of the result of this expression 9/5 will be:
Syntax
The grammar of a programming language is called its ____________.
Semantics
The meaning of a programming language's statements is called its _____________.
Python dynamic typing
All variables are untyped Any variable can name any thing, but all things or values have a type Type-checking occurs at runtime
reference semantics
assignment produces two references to the same object
Destructors
called when an object is deallocated (either going out of scope or use delete operater) Name is preceded the tilde symbol (~)
Data structure
collects related data values into a single unit
Orthogonal design
constructs can be combined in any meaningful way, with no unexpected restrictions or behaviors In a language that is truly orthogonal, constructs do not behave differently in different contexts Example: function return types
Grammar
formal definition of the language's syntax
Uniformity
a design in which similar things look similar and have similar meanings while different things look different
Application programming interface (API)
gives information about the resource's components
Basic control abstractions
statements that combine a few machine instructions into an abstract statement that is easier to understand
Lexical structure
structure of the language's words
Writability
the quality of a language that enables a programmer to use it to express computation clearly, correctly, concisely, and quickly
Efficiency
usually thought of as efficiency of the target code Example: strong data typing, enforced at compile time, means that the runtime does not need to check the data types before executing operations
value semantics
values are copied during assignment)
True
( true or false )Python dynamic typing makes it not suitable for critical applications
True
(true or false) Class member functions can be implemented outside the class declaration by using the scope resolution operator ::
Compiler
A(n) ____ translates an entire program into executable code and does not execute it.
ALGOL
ALGOrithmic Language released in 1960 Included structured control statements (for loop, if conditions if-else etc) Supported different numeric types Introduced the array structure Supported procedures, including recursive procedures
scope resolution operator
:: after a class name
def
A Python function definition starts with:
Semantically safe
A language is considered to be __________ if it prevents a programmer from compiling or executing any statements or expressions that violate the definition of the language.
Extensible
A language is considered to be __________ if you can add features to it.
Uniformity
A language lacks ________ when dissimilar things look or behave similarly
Imperative language
A language requires that a program be described as a sequence of instructions
Generality
A language with this property avoids special cases wherever possible achieved by avoiding special cases in the availability or use of constructs and by combining closely related constructs into a single more general one
Logic paradigm
Based on symbolic logic
Functional paradigm
Based on the abstract notion of a function in calculus
C++ created by
Bjarne Stroustrup and that he added the class construction from Simula67 language Compiler was called Cfront
FORTRAN
FORmula TRANslation language Developed by John Backus in the early 1950s Lacked the structured control statements and data structures of later high-level languages
Restricting access to internal details of software components
Encapsulation is:
Python can be run in two modes:
Expressions or statements can be run in a Python shell for maximum interactivity Can be composed into longer scripts saved in files and run from a terminal command prompt
who developed Python?
Guido van Rossum developed a translator and virtual machine for a scripting language called Python in 1986 One of his goals was to allow Python to act as a bridge between system languages such as C and shell or scripting languages such as Perl
Structured control abstractions
Help to express the logic of primary control structures of sequencing, selection, and iteration
Basic data abstraction
Hides internal representation of common data values
Orthogonal
If a language is ________, its constructs do not behave differently in different contexts.
' Bob'
If greet = "Hello Bob" then greet[5:9] will give back:
spamspameggseggseggs
If x="spam" and y="eggs" then print(x*2 + y*3) will print:
#
In Python, a comment line start with:
Simula
Object-oriented programming languages began in with __________.
languages descended from ALGOL
Pascal and Ada
Object-oriented paradigm
Reusable code that operates in a way to mimic behaviors of real-world objects
Members are inaccessible to client code but are accessible to derived classes
The protected access modifier means:
Python
The the following programming language uses a virtual machine to translate it's source code into a byte code:
Both
To enable dynamic binding of member functions in C++, you need: 1) Object must be either dynamically allocated or otherwise accessed through a reference 2) functions defined with the keyword virtual 3) Both
input
To get input from the user we use the following command:
import
To make the functions of a certain library available we must use:
False
True or False: Assembly language is machine-independent
True
True or False: Backwards compatibility with another language may be a valid cause of irregularity.
False
True or False: C++ uses a garbage collector mechanism to handle objects no longer needed.
True
True or False: Early dialects of FORTRAN supported static storage allocation only.
True
True or False: There is no generally accepted standard formal method for describing the semantics of a programming language.
Both
What important needs in software design does Object-oriented programming languages satisfy 1) Maintain the independence of different components 2) Separating interfaces from implementations 3) both
break
What statement can be executed in the body of a loop to cause it to terminate:
Simple regular syntax
Which of the following is not a design goal for C++:
Both
Which ways can help improve software reuse: 1) Abstraction 2) Polymorphism 3) Both
Template
________ classes are used to define generic collections in C++.
Efficiency of execution
________ was the first primary goal of early programming languages.
Expressiveness
_________ is the property of how easy it is to express complex processes and structures.
Assembly Language
______________ was the first programming language to use mnemonic symbols to represent binary machine codes.
Abstraction
________________ is the mechanism that makes programs easier to write and easier for people to read.
Pure virtual declaration
a function declared with a 0 and the keyword virtual
Extensible language
a language that allows the user to add features to it Example: the ability to define new data types and new operations (functions or procedures)
Syntactic sugar
a mechanism that allows you to replace a complex notation with a simpler, shorthand notation
programming language often defined as:
a notation for communicating to a computer what we want it to do
Translator
a program that accepts other programs and either directly executes them or transforms them into a form suitable for execution
Loader
a program that loads the machine code into computer memory
Assembler
a program that translates the symbolic assembly language code to binary machine code
Assembly language
a set of mnemonic symbols for instruction codes and memory locations
Unit
a stand-alone collection of procedures providing logically related services to other parts of a program Allows a program to be understood as a whole without needing to know the details of the services provided by the unit
Interpreter
executes a program directly one step process
Expressiveness
how easy is it to express complex processes and structures
Constructors
initialize objects as in Java-Can be called automatically as part of a declaration, as well as in a new expression
Branch instructions
instructions that support selection and iteration to memory locations other than the next one
Implementation
internal representation of data values and operations
Semantically safe
languages that prevent a programmer from compiling or executing any statements or expressions that violate the language definition
maintainability
may be the most important index of programming language efficiency
public
members are accessible to client code and derived classes
Private
members are inaccessible to client and to derived classes (default)
Protected
members are inaccessible to client code but are accessible to derived classes
Data types
names given to kinds of data values
Unit abstraction
often associated with the concept of an abstract data type
Polymorphism
overloading, is an example of:
Compiler
produces an equivalent program in a form suitable for execution two step process
Lisp
programming language that uses the functional model of computation
John von Neumann
proposed that computers should be permanently hardwired with a small set of general-purpose operations
0,1,2,3,4
range(5) will generate the following numbers:
Regularity
refers to how well the features of a language are integrated
Interface
set of operations available to the user
Language syntax
similar to the grammar of a natural language
Control abstractions
simplify properties of the transfer of control Examples: loops, conditional statements, procedure calls
Data abstractions
simplify the behavior and attributes of data for humans Examples: numbers, character strings, search trees
Macro
specifies the syntax of a piece of code that expands to other standard code when compiled
Opcode
the first 4 bits of a line of code
Tokens
the language's words Includes keywords, identifiers, symbols for operations, special punctuation symbols, etc.
Compiler
translates programming language statements into machine code
Variables
use of symbolic names to hide computer memory locations containing data values
Template classes
used to define generic collections in C++