Topics for Test 2 -- Spring 2018
- Updates :
- 2018 Apr 14 09:44:08 PM: Finalized for Spring 18. Made minor additions in 2 places - marked with bold italics.
Struck through several topics to indicate that they are NOT be on the exam.
- 2018 Apr 13 03:57:24 PM: Slight modifications based on class discussion
- 2018 Apr 13 10:00:46 AM: First version for spr 18
- Material
- Material from class and web page notes since material from last
exam
- From the text: As related to material covered in class and as
mentioned in the web pages, but mostly
8.7, 2.4 (records) and 11 (packages)
- Records
- List and briefly describe similarities and differences between classes and records.
- For each of the pairs of terms below, define the terms and explain how they relate to records and classes:
- Composite type and primitive type
- Reference type and primitive type
- User-defined type and primitive type
- Define and appropriately use the term field as it relates to records and classes
- Define the term struct as it relates to records.
- Contrast arrays and records with respect to the type of their components and how they access their components.
- Operations with records - describe how each operates, be able to use the operation:
- Declaration of variables and Allocation of memory
- Contrast the declaration of (record or class) type vs declaration and allocation of variable of that type
- Access to fields (ie the dot)
- Assignment (ie field by field)
- Equality test (ie field by field)
- Defining new operations (ie define procedures and functions with record type parameters)
- Contrast default values for fields of Ada records vs those of Java objects (ie what value is in a variable or
object that is not explicitly
initialized).
- Nested Composite Types:
- Explain what is meant by a nested composite type (ie fields are themselves composite types)
- Declare an Ada record type that is a nested composite types
- Contrast Ada and Java with respect to underlying implementation of records whose fields are record types and classes whose fields are objects
- Draw diagram showing memory allocation of Ada and Java nested composite objects
- Explain Java code that instantiates nested composite object
- Aggregation vs Composition:
- Describe conceptual difference in these two kinds of association, as related to ownership and lifetime
- Describe the natural implementation in Ada vs the less natural Java implementation
- Nested arrays and records (eg Arrays of Records of Arrays):
- Be able to define and use nested arrays and records
- Example: record containing an array of records and a length field
- Value vs reference semantics:
- Give Examples
- Define primitive vs composite (ie structured) types in
this context
- Compare with Java as related to creation and allocation of composite values
- Describe, recognize, and explain errors that can occur because of the difference in reference and value semantics:
- Problem: Assign item to a variable and use the variable to modify the item
- Example: Modifying field of nested composite record
- Example: Modifying element of an array
- Benefits and drawbacks
- ADTs:
- Definition of abstract and ADT
- Relation to classes, packages, and records
- Packages:
- Define the term package as used in Ada.
- Define the term client
- Package Specification and Body:
- Specification (.ads): describe what it contains (ie public and private
sections), visibility to client and body, relation to body
- Body (.adb): describe what it contains, visibility to client,
relation to specification
- Motivation for packages:
- Explain why we create packages
- Explain the relation of packages to ADT's, including what package features allow creation of an ADT
- Be able to write a simple package
- Be familiar with specification and implementation of and be able to use
wordpkg, bignumpkg, and stacks and queues
implemented as arrays
- Private types :
- Explain what it means for a type to be declared as private
- Describe how to create a private type (or just create one)
- Describe what is public and private about a type used to define and ADT
- Explain the operation of and compare and contrast Ada with and use,
Java import, and C/C++ include (eg what they do, are they transitive?)
- Child packages
- Explain the visibility among the spec and body of the child and parent and a client of both
- Explain several uses for and/or benefits of child packages
- Generic Packages
- Describe the purpose of a generic package
- Describe what a generic package has that a regular package does not
- Instantiation: with but no use, create new package, use new package
- Explain when an instance of a generic package is typically
(ie in the examples in this class) created
- Explain the role of the parameters of a generic package
- Explain what kinds of things can be used as parameters of a generic package
- Create a simple generic package
- Define, recognize, and use the term instantiate as it relates to packages
- Comparison with Java
- Describe what Java language feature is closely related to generic packages
- Explain the type checking problems that occur with Java arrays and other containers of Objects and how this problem is solved with Java
generic types
- Define the term template as it relates to generic procedures and functions. [Generic in C++]
- Compare and contrast Ada Records and Java Classes in each of these areas:
- Memory allocation template
- Encapsulation
- Access control (Java keyword private vs Ada packages)
- Underlying semantics
- User defined types (Java always has reference semantics)
- Composition of types (Java always has fields that are pointers, Ada can have value sematics record types as fields)
- Some differences Ada records and Java classes:
- Composite types are provided by records and classes in Ada and Java, respectively
- A value of a record type is like a Java object: both have fields, but Ada does no require pointers
- Class contains methods that operations on instances of the class vs Ada defines procedures and functions that operate on a record type
- Draw diagram showing memory allocated for declaration and allocation of record and class variables and objects
- Classes vs packages
- Define the term conflate
- Contrast how Ada and Java separate and conflate, respectively, the concepts of type and module.
- Explain several ways in which a class is used: eg, type for declaring reference variables, template for creating objects,
location for declaring methods that operate on instances of the type, library of methods (eg Math)
- Contrast the above ways a class is used with how similar concepts are implemented in Ada
- Describe and illustrate how OO languages have implicit parameters to procedure vs how Ada programs have explicit parameters
- Explain the role of this in relation to implicit parameters
- Enumerated types:
- Define and/or explain what an enumerated type is
- Explain the motivation for them
- Understand and write an appropriate declaration for an enumerated type
- List and use some operations and attributes on enumerated types
- Explain how IO for enumerated types is accomplished (ie generic packages) and why this approach is needed
- Describe approaches taken for enumerated types in Java and C and the pros and cons of these approaches [Not on Spr 18 exam2]
- Other topics:
- Look_Ahead: parameters, operation, purpose
- Buzz numbers: 2^10, etc
- Signed + Magnitude negative numbers
- 9's Complement
The following are not on Spring 2018 Exam 2
- Axiomatic definition of stacks
- Floating point numbers: representation, range and precision
- Exceptions:
- Write an exception handler to handle common, language-defined exceptions
- Use declare and begin-end blocks appropriately to check exceptions within a specified area of code
- Describe and interpret the flow of control associated with exceptions
- Declare exceptions
- Raise exceptions in a package, and handle them in a client.
- ADTs: motivation, kinds of operations
- Variant records
- Motivation
- Basic implementation in Ada
- Security issues and their solutions
- Basic implementation in other languages (concepts, not syntax)
- Parnas Principle
- Deep and shallow copy
- Private types vs limited private types: definition and motivation
- State what operations are not available for limited private types
- Generic Procedures
- Explain what a generic procedure is
- Explain the benefit of having generic procedures
- Describe some example generic procedures
- Structure charts: sequence, loop, if, information passing, procedures
- Use as a design tool
- Sequence, loop, if, information passing, procedures