Chapter 11 - Abstract data types Flashcards

1
Q

what is an abstraction?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is an abstract data type?

A
  • a data representation of one specific data type

- the subprograms that provide the operations for that type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

6 Design issues for abstract data types

A
  • what is the form of the container
  • what types can be abstract
  • can abstract types be parameterized
  • what access controls are provided
  • is the specification of the type physically separate from its implementation
  • should general built-in operations be provided from objects of abstract data types
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is an object

A

an instance of an abstract data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the encapsulation construct in Ada

A

the package

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

4 characteristics of C++ class

A
  • an encapsulation device
  • all class instances share a single copy of the member functions
  • each instance of a class has its own copy of the class data members
  • instances can be static, stack dynamic, or heap dynamic
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

6 characteristics of C++ constructors

A
  • they initialize objects
  • may allocate storage for any parts that are heap-dynamic
  • can include parameters to provide parameterization of the objects
  • implicitly called when an instance is created
  • can be explicitly called
  • name the same as class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

5 characteristics of C++ destructors

A
  • implicitly called when the lifetime of an instance of the class ends
  • often used for delete of heap-dynamic data allocated within the class
  • often used for debugging or statistical analysis
  • can be explicitly called
  • the name is ~class_name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

3 differences of Java objects than C++ objects

A
  • all objects are allocated on the heap and accessed through reference variables
  • individual entities in classes have access modifiers (public, private) rather than clauses
  • has an extra scoping mechanism “package scope” to be used in place of friends
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

3 characteristics of abstract data types in C#

A
  • all class instances are heap dynamic
  • default constructors are predefined for all classes
  • C# allows destructors but it uses garbage collection so they are rarely used
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

6 characteristics of C# structs

A
  • they can have constructors, properties, methods, and data fields
  • can implement interfaces but do not support inheritance
  • they are value types (their data is allocated to memory on the stack)
  • they default to pass by value when used as parameters
  • they can be declared like other types
  • they can also be created using new operator with invokes the constructor
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

3 characteristics of Ruby classes (that I probably don’t know)

A

class methods are distinguished from instance methods by having a class name appended to the beginning of their names with a dot separator

constructors are called “initialize”

classes can be “updated” any place in the text

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Ruby undef_method vs remove_method

A

undef_method - blocks any reference to a given method

remove_method - block deletes method from class but allows those class objects to look for method definition in parent

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

4 characteristics of information hiding in Ruby

A
  • access control violations are only detected at runtime
  • uses public (default), protected, and private
  • all data members of a class are private and cannot be changed
  • data access is via methods only
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is an encapsulation construct?

A

-a way of organizing programs into collections of logically related code and data, each of which can be compiled without recompilation of the rest of the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Examples of encapsulation constructs in C, C++, Ada, C#

A

C –> header and implementation files

C++ –> header/implementation and class header/implemenatation files

Ada –> packages (can include any number of interfaces to ADTs)

C# –> assemblies (mimics a dll or exe)

17
Q

why use named encapsulations?

A

when dealing with large programs written by many coders working independently named encapsulations define scopes that help avoid name collisions/duplication

18
Q

4 examples of named encapsulation?

A

C++ namespace

Java package

Ada package

Ruby modules

19
Q

5 characteristics of Java packages

A
  • may contain multiple type definitions
  • all types in the package are partial friends
  • package declaration must be the first line of the file
  • all types outside of a package are part of the default unnamed Java package
  • access similar to C++ (add using import blah)
20
Q

2 things for using Ada package data

A
  • visibility to the package is gained by using “with” clause
  • member references must be qualified “Ada.pkg_name.method or use the “use” clause

use Ada.pkg_name
method…

21
Q

6 characteristics of Ruby modules

A
  • may contain methods and constants
  • cannot define variables
  • cannot be instantiated
  • cannot be inherited
  • a method defined in a module must include the module name
  • clients access module first by “require” then by module name