Theory of Programming Languages Ch11

0.0(0)
studied byStudied by 8 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/38

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.

39 Terms

1
New cards

What is abstraction in programming/computer science?

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

2
New cards

What two conditions must a user-defined ADT satisfy?

The type and its operations are declared in a single syntactic unit; only declared operations can be performed on the type

3
New cards

How do abstraction and information hiding differ?

Abstraction is a high-level view independent of implementation; information hiding conceals irrelevant implementation details

4
New cards

Give two advantages of declaring an ADT and its operations in one syntactic unit.

Improved organization and maintainability; supports separate compilation and reuse

5
New cards

What is a key advantage of restricting ADT operations to those declared for the ADT?

The implementation can change without affecting client code

6
New cards

List two primitive operations languages typically supply for ADTs.

Assignment/cloning; equality comparison; serialization

7
New cards

What are the two possible ADT orientations?

Procedure-oriented and object-oriented

8
New cards

Name a procedure-oriented programming language.

Ada

9
New cards

How do you push onto a procedure-oriented ADT stack syntactically?

Push(Stack, 42)

10
New cards

How do you push onto an object-oriented ADT stack syntactically?

stack.push(42)

11
New cards

What key feature do object-oriented ADTs provide that procedure-oriented ADTs do not?

Inheritance

12
New cards

Which ADT orientation is superior for readability?

Object-oriented ADTs

13
New cards

Which ADT orientation is superior for writability?

Object-oriented ADTs

14
New cards

Which ADT orientation is superior for reliability?

Procedure-oriented ADTs

15
New cards

Why do C++ classes support destructors as well as constructors?

Because C++ lacks garbage collection and must explicitly free heap storage

16
New cards

What is a key difference between Ruby classes and classes in C++, Java, and C#?

Ruby classes are dynamic and can be modified at runtime

17
New cards

What is encapsulation in computer science?

The bundling of related data and operations, often with information hiding

18
New cards

What is the relationship between encapsulation and ADTs?

ADTs are one form of encapsulation that bundle data with operations

19
New cards

List two forms of encapsulation other than ADTs.

Nested subprograms; file encapsulation; component encapsulation

20
New cards

What primary Java feature supports the creation of components?

Packages

21
New cards

What two things are required to include a Java class in a package?

Add a package declaration and place the file in the corresponding directory

22
New cards

Where is a public Java instance variable visible?

Everywhere

23
New cards

Where is a private Java instance variable visible?

Only within the defining class

24
New cards

Where is a package-level Java instance variable visible?

To all classes in the same package

25
New cards

What is the purpose of a namespace?

To create a new scope for names and avoid name conflicts

26
New cards

What keyword defines namespaces in Java?

package

27
New cards

What keyword defines namespaces in Ruby?

module

28
New cards

What keyword defines namespaces in C++?

namespace

29
New cards

How can C++ private variables potentially be accessed outside the class?

Through friend classes

30
New cards

What Ruby feature other than inheritance can violate ADT conditions?

Dynamic modification of classes at runtime

31
New cards

What Java keyword allows a method to be called on the class itself?

static

32
New cards

How does declaring an ArrayList variable as static affect its usage?

The variable is shared by all instances of the class

33
New cards

How can procedure-oriented ADTs be simulated in Java?

Using class methods that operate on objects passed as parameters

34
New cards

Why can object-oriented ADTs not be simulated in purely procedural languages?

Because procedural languages lack methods bound to objects and inheritance

35
New cards

Give two purposes of a Java package.

Create components and provide a namespace

36
New cards

What is the access level of a Java member with no access modifier?

Package-private

37
New cards

What is a friend class in C++?

A class granted access to another class’s private members

38
New cards

How can friend-class behavior be approximated in Java?

Using package-private members visible to all classes in the same package

39
New cards