pl finals

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/23

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

24 Terms

1
New cards

Abstraction

  • is a view or representation of an entity that includes only the most significant attributes

2
New cards

abstract data type

  • it is a user-defined data type that satisfies two conditions

3
New cards

adt first condition

  • 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

4
New cards

adt second condition

  • 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

5
New cards

adt first condition advantages

  • 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 changes without affecting user code

  • reduces the range of code and variables of which the programmer must be aware

  • name conflicts are less likely

6
New cards

adt second condition advantages

  • provides a method of program organization

  • aids modifiability (everything associated with a data structure is together)

  • separate compilation

7
New cards

adt language requirements

  • a 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

8
New cards

adt design issues

  • can abstract data be parameterized?

  • what access controls are provided?

  • is the specification of the type physically separate from its implementation?

9
New cards

adt C++

  • based on C struct

  • a class is a type

  • the class is the encapsulation device

  • each instance of a class has its own copy of the class data members

  • instances can be static, stack dynamic, or heap dynamic

10
New cards

C++ information hiding

  • Private clause for hidden entities

  • Public clause for interface entities

  • Protected clause for inheritance

11
New cards

C++ constructors

  • 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

12
New cards

C++ destructors

  • functions to cleanup after an instance or 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 (~)

13
New cards

Friend Functions or classes

  • to provide access to private members to some unrelated units or functions

14
New cards

adt Java

  • all user-defined types are classes

  • all objects are allocated from the heap and accessed through reference variables

  • individual entities in classes have access control modifiers (private or public), rather than clauses

  • implicit garbage collection of all objects

  • it has second scoping mechanism, package scope, which can be used in place of friends

15
New cards

adt c#

  • based on C++ and Java

  • adds two access modifiers, internal and protected internal

  • all class instances are heap dynamic

  • default constructors are available for all classes

  • garbage collection is used for most heap objects, so destructors are rarely used

  • structs are lightweight classes that do not support inheritance

16
New cards

parameterized adt

  • it allows designing an ADT that can store any type elements - only an issue for static typed languages

  • also known as generic classes

17
New cards

java parameterized adt

  • most common generic types are the collection types, such as LinkedList and ArrayList

18
New cards

large program needs

  • some means of organization, other than simply division into subprograms

  • some means of partial compilation (compilation units that are smaller than the whole program)

19
New cards

encapsulation

  • solves the large program needs

  • it is a grouping of subprograms that are logically related into a unit that can be separately compiled (compilation units)

20
New cards

nested subprograms

  • organizing programs by nesting subprogram definitions inside the logically larger subprograms that use them

21
New cards

C encapsulation

  • files containing one or more subprograms can be independently compiled

  • the interface is placed in a header file

  • #include preprocessor specification—used to include header files in applications

22
New cards

C encapsulation problems

  • the linker does not check types between a header and associated implementation

  • the inherent problem with pointers

23
New cards

C++ Encapsulation

  • can define header and code files, similar to those of C

  • Or, class can be used for encapsulation

    • the class is used as the interface (prototypes)

    • the member definitions are defined in a separate file

  • friends provide a way to grant access to private members of a class

24
New cards

naming encapsulations

  • large programs define many global names; need a way to divide into logical groupings

  • this is used to create a new scope for names