Flashcards
Organization of Programming Languages Chapter 11
Cards in this deck (40)
- 1This is a view or representation of an entity that includes only the most significant attributesabstraction
- 2(true/false) Nearly all programming languages support process abstraction with subprogramsTrue
- 3Which 2 conditions need to be satisfied to have a user defined abstract data type?-the representation of objects of the type is hidden from the program units that use these objects, so the only operations possible are those provided in the type's definition-The declaration of the type and the protocols of the operations on objects of the type are contained in a single syntactic unit. Other program units are allowed to create variables of the defined type.
- 4What are the advantages of the first condition of abstraction? (The representation of objects of the type is hidden from the program units that use these objects, so the only operations possible are those provided in the type's definition)Reliability--by hiding the data representations, user code cannot directly access objects of the type or depend on the representation, allowing the representation to be changed without affecting user code
Reduces the range of code and variables of which the programmer must be aware
Name conflicts are less likely - 5what are some advantages of the Second condition of abstraction? (The declarations of the type and the protocols of the operations on objects of the type are contained in a single syntactic unit. Other program units are allowed to create variables of the defined type.)-Provides a method of program organization
-Aids modifiability (everything associated with a data structure is together) - 6What are Language requirements for an ADT-Syntactic unit in which to encapsulate the type definition
-A method of making type names and subprogram headers visible to clients, while hiding actual definitions
-Some primitive operations must be built into the language processor - 7What are some design issues of abstract data typesCan abstract types be parameterized?
What access controls are provided?
Is the specification of the type physically separate from its implementation? - 8What are some characteristics of a constructor (C++)?-Functions to initialize the data members of instances (they do not create the objects)
-May also allocate storage if part of the object is heap-dynamic
-Can include parameters to provide parameterization of the objects
-Implicitly called when an instance is created
-Can be explicitly called
-Name is the same as the class name - 9What are the characteristics of destructors? (C++)-Functions to cleanup after an instance is destroyed; usually just to reclaim heap storage
-Implicitly called when the object’s lifetime ends
-Can be explicitly called
-Name is the class name, preceded by a tilde (~) - 10What is it that provides access to private members to to some unrelated units or functionsFriend functions or classes
Necessary in C++ - 11What are constructors called?Initializers - all they do is initialize variables
(objective-C) - 12what are some characteristics of Initializers?-Initializers can have any name - they are always called explicitly
-Initializers always return self - 13In Objective-C how are objects created?Created by calling "alloc" and the constructor
Adder *myAdder = [[Adder alloc] init]; - 14All class instances are what?heap dynamic
- 15With regards to information hiding, which directives are used to specify the access of instance variables? (Objective-C)@private
@public - 16With regards to information hiding, what is the default access in objective-C and C++Objective-C: protected
C++: private - 17Parameterized ADTs allow designing an ADT that can store what?any type elements
(only an issue for static typed languages) - 18A parameterized ADT that can store any type elements are also known as what?Generic Classes
- 19which programming languages provide support for parameterized ADTs?C++, Java 5.0, and C# 2005
- 20how can class be made somewhat generic?by writing parameterized constructor functions
- 21what are the 2 special needs that programs have?-Some means of organization, other than simply division into subprograms
-Some means of partial compilation (compilation units that are smaller than the whole program) - 22A grouping of subprograms that are logically related into a unit that can be separately compiled (compilation units)Such collections are called encapsulation
- 23Organizing programs by nesting subprogram definitions inside the logically larger subprograms that use themNested Subprograms
- 24In C, files containing one or more subprograms can what?be independently compiled
- 25In C, where is the interface placed?a header file
- 26What are 2 encapsulation problems in C?Problem 1: the linker does not check types between a header and associated implementation
Problem 2: the inherent problems with pointers - 27In C, what is the preprocessor specification - used to include header files in applications?#include
- 28In what ways can classes in C++ be used for encapsulation?-The class is used as the interface (prototypes)
-The member definitions are defined in a separate file - 29In C++ what keyword is used to grant access to private members of a class?Friends
- 30A collection of files that appears to application programs to be a single dynamic link library or executableC# Assemblies
- 31This is a collection of classes and methods that are individually linked to an executing programDLL (Dynamically linked libraries)
- 32A C# access modifier that gives a member visibility to all classes in the assembly in which it appearsinternal
- 33What is used to create a new scope for names?Naming Encapsulation
Large programs define many global names; need a way to divide into logical groupings - 34Describe C++ Namespaces-can place each library in its own namespace and qualify names used outside with the namespace
=C# also includes namespaces - 35Describe Java packages-Packages can contain more than one class definition; classes in a package are partial friends
-Client of a package can use fully qualified name or use the import declaration - 36Along with classes and name encapsulations, Ruby also has...modules
- 37In Ruby what is typically encapsulated?constants and methods
- 38what are things that Modules cannot do in Ruby?cannot be instantiated or subclassed, and they cannot define variables
- 39what must methods defined in a ruby module have included?the modules name
- 40how is access to the contents of a Ruby module requested?with the require method
Information
- Description
- Social Issues and Ethics in CS Flashcards on Organization of Programming Languages Chapter 11, created by James Herd on 25/04/2019.
- Created by
- James Herd
- Views
- 0
- Rating