GoConqr has a new look! Let us know what you think.

Flashcards

Organization of Programming Langs Chapter 12

James Herd Social Issues and Ethics in CS English 94 cards

Cards in this deck (94)

  1. 1What are the 3 major language features of OOP Languages?Abstract data types
    Inheritance
    Polymorphism
  2. 2Explain what inheritance allowsAllows new classes defined in terms of existing ones, i.e., by allowing them to inherit common parts
  3. 3What concerns does inheritance address?reuse ADTs after minor changes and define classes in a hierarchy
  4. 4What are ADTs ussually called?Classes
  5. 5what is Class instances called?Objects
  6. 6What is the class from which another class inherits?superclass
  7. 7What is the term for subprograms that define operations on objects?methods
  8. 8What are calls to methods called?messages
  9. 9What is the entire collection of methods of an object called?Message protocol or message interface
  10. 10what are the two parts of a method?the method name and the destination object
  11. 11In the simplest case, what does a class inherit?all of the entities of its parent
  12. 12Inheritance can be complicated by access controls to encapsulated entities, in which ways can a class hide entities?-a class can hide entities from its subclasses
    -a class can hide entities from its clients
    -A class can also hide entities for its clients while allowing its subclasses to see them
  13. 13what are the 3 ways that a class can differ from its parent?1. the subclass can add variables and/or methods to those inherited from the parent
    2. the subclass can modify the behavior of one or more of its inherited methods
    3. the parent class can define some of its variables or methods to have private access, which means they will not be visible in the subclass
  14. 14what are the two kinds of variables in a class?Class variables - one/class
    Instance variables - one/object
  15. 15What are the two kinds of methods in a class?Class methods - accept messages to class
    Instance methods - accepts messages to objects
  16. 16What is a disadvantage of inheritance for reuse?creates inter-dependencies among classes that complicate maintenance
  17. 17How can a polymorphic variable be defined?can be defined in a class that is able to reference (or point to) objects of the class and objects of any of its descendants
  18. 18What kind of binding takes place when a class hierarchy includes classes that override methods and such methods are called through a polymorphic variable?Dynamic Binding
  19. 19What is it when a method does not include a definition (it only defines a protocol)An abstract method
  20. 20name 2 properties of an abstract class1. is a class that includes at least one virtual method
    2. An abstract class cannot be instantiated
  21. 21What are some design issues for OOP Languages?-The Exclusivity of Objects
    -Are Subclasses Subtypes?
    -Single and Multiple Inheritance
    -Object Allocation and Deallocation
    -Dynamic and Static Binding
    -Nested Classes
    -Initialization of Objects
  22. 22What are the advantages and disadvantages of making everything an object when designing an OOP Lang?Advantages - elegance and purity
    Disadvantage - Slow operations on simple objects
  23. 23What are the advantages and disadvantages of adding objects to a complete typing system when designing an OOP Lang?Advantage - fast operations on simple objects
    Disadvantage - results in a confusing type system (two kinds of entities)
  24. 24Does an “is-a” relationship hold between a parent class object and an object of the subclass?If a derived class is-a parent class, then objects of the derived class must behave the same as the parent class object
  25. 25When is a derived class a subtype?if it has an "is-a" relationshp with the parent class
  26. 26What do subclass have the ability to do?add variables and methods and override inherited methods in "compatible" ways
  27. 27What do Subclasses inherit?implementations
  28. 28What do subtypes inheritinterface and behavior
  29. 29What does Multiple inheritance allow?allows a new class to inherit from two or more classes
  30. 30Name some disadvantages of multiple inheritance-Language and implementation complexity (in part due to name collisions)
    -Potential inefficiency - dynamic binding costs more with multiple inheritance (but not much)
  31. 31What is an advantage of Multiple inheritance?Sometimes it is quite convenient and valuable
  32. 32From where can objects be allocated if they behave like ADTs?-They can be allocated anywhere
    -Allocated from the run-time Stack
    -Explicitly create on the heap (via new)
  33. 33From where are objects allocated if they are all heap-dynamic?-references can be uniform thru a pointer or reference variable
  34. 34From where are objects allocated if objects are stack dynamic?-there is a with regard to subtypes -object slicing
  35. 35Should all binding of messages to methods be dynamic?-If none are, you lose the advantages of dynamic binding
    -If all are, it is inefficient
  36. 36What do you use when a new class is need by only one class?use a nested class
  37. 37Name an issue with a nested classYou don't know which facilities of the nesting class should be visible to nested class and vice versa
  38. 38(True/False) the programming language Smalltalk is a pure OOP in languageTrue
  39. 39Name some of the properties of a pure OOP Language-Everything is an object
    -All objects have local memory
    -All computation is through objects sending messages to objects
    -None of the appearances of imperative languages
    -All objected are allocated from the heap
    -All deallocation is implicit
    -Smalltalk classes cannot be nested in other classes
  40. 40What type of binding takes place in smalltalk when binding messages to messagesDynamic binding
  41. 41Is there type checking in Smalltalk? if so describe itonly type checking in smalltalk is dynamic and the only type error that occurs is when a message is sent to an object that has no matching method
  42. 42What programming language is among the most widely used OOP languageC++
  43. 43describe inheritance as it relates to C++-A class need not be the subclass of any class
    -Access controls fro members are Private, Public, Protected)
  44. 44How can a member that is not accessible in a subclass (because of private derivation) can be declared to be visible in C++?using the scope resolution operator (::)
    class subclass_3 : private base_class {
    base_class :: c;
    …
    }
  45. 45What is the motivation for using private derivation?A class provides members that must be visible, so they are defined to be public members; a derived class adds some new members, but does not want its clients to see the members of the parent class, even though they had to be public in the parent class definition
  46. 46How can multiple inheritance be supported in C++If there are two inherited members with the same name, they can both be referenced using the scope resolution operator (::)
  47. 47How is Dynamic Binding used in C++-A method can be defined to be virtual, which means that they can be called through polymorphic variables and dynamically bound to messages
    -A pure virtual function has no definition at all
    -A class that has at least one pure virtual function is an abstract class
  48. 48(True/False) Because of interpretation and dynamic binding, Smalltalk is -10 times slower than C++True
  49. 49In C++ are methods statically bound or Dynamically bound?Both
    Programmer decides at design time
  50. 50What is the largest syntactic difference between C++ and Objective-C?Method calls
  51. 51(True/False) Classes can be nested in Objective-CFalse
    They cannon be nested
  52. 52In Objective-C which section of a class declares the instance variables and the methods?Interface Section
  53. 53In Objective-C Which section of a class defines the methodsthe Implementation section
  54. 54Describe Inheritance for Objective-C-Single inheritance only
    -Every class must have a parent
    -NSObject is the base class
    @interface myNewClass: NSObject { … }
    …
    @end
    -Because all public members of a base class are also public in the derived class all subclasses are subtypes
    -Any method that has the same name, same return type, and same number and types of parameters as an inherited method overrides the inherited method
    -An overriden method can be called through super
    -All inheritance is public (unlike C++)
  55. 55In Objective-C what are the 2 other approaches to inheritance besides subclassing to extend a class?-Category
    -protocols
  56. 56This is a secondary interface of a class that contains declarations of methods (no instance variables)category
  57. 57This is a category where its methods are added to the parent class (things available to child class but is included)Mixin
  58. 58This is another way to extend a class and consists of a list of method declarations (Objective-C)Protocols
  59. 59How is dynamic binding implemented in Objective-C?-Different from other OOP languages – a polymorphic variable is of type id
    -An id type variable can reference any object
    -The run-time system keeps track of the type of the object that an id type variable references
    -If a call to a method is made through an id type variable, the binding to the method is dynamic
  60. 60For Objective-C how do you prevent overriding an inherited methodYou can't, no derivation
  61. 61What are useful additions to OOP that Objective-C brought to the table?Categories and protocols
  62. 62What are some general characteristics of OOP in Java?-All data are objects except the primitive types
    -All primitive types have wrapper classes that store one data value
    -All objects are heap-dynamic, are referenced through reference variables, and most are allocated with new
    -A finalize method is implicitly called when the garbage collector is about to reclaim the storage occupied by the object
  63. 63In Java, multiple inheritance is not supported but what abstract class category provides some of the benefits of multiple inheritance?Interface
  64. 64This can include only method declarations and named constantsInterface
  65. 65Methods that have this keyword cannot be overridenfinal
  66. 66(True/false) All subclasses in java are subtypesTrue
  67. 67In what way is Dynamic binding used in Java?all messages are dynamically bound to methods, unless the method is final (it cannot be overridden, therefore dynamic binding serves no purpose
  68. 68In what ways is Static binding used in Java?used if method is static or private of which disallow overriding
  69. 69This allows polymorphic variables to be bound?Dynamic Binding
  70. 70This is a Nonstatic classes nested directlyinnerclasses
  71. 71what are 2 properties of innerclasses-innerclasses can access members of its nesting class
    -static nested class cannont access members of its nesting class
  72. 72What are some properties of nested classes? (Java)-All are hidden from all classes in their package, except for nesting class
    -Nested classes can be anonymous
    -A local nested class is defined in a method of its nesting class
  73. 73(True/False) there are no parentless classes in JavaTrue
  74. 74What are some characteristics of OOP in C#?-Support for OOP similar to Java
    -Includes both classes and structs
    -Classes are similar to Java's classes
    -structs are less powerful stack-dynamic constructs(no inheritance)
  75. 75Describe the inheritance of C#-Uses the syntax of C++ for defining classes
    -A method inherited from parent class can be replaced in the derived class by marking its definition with new
    -The parent class version can still be called explicitly with the prefix base:
    base.Draw()
    -Subclasses are subtypes if no members of the
    parent class is private
    - Single inheritance only
  76. 76How is dynamic binding of method calls to methods allowed in C#-the base class method is marked virtual
    -the corresponding methods in derived classes are marked override
  77. 77(True/False) All C# classes are ultimately derived from a single root classTrue
    object, just like Java
  78. 78Describe nested classes for C#-A C# class that is directly nested in a nesting class behaves like a Java static nested class
    -C# does not support nested classes that behave like the non-static classes of Java
  79. 79What are some general characteristics of OOP in Ruby-Everything is an object
    -All computation is through message passing
    -Class definitions are executable, allowing secondary definitions to add members to existing definitions
    -Method definitions are also executable
    -All variables are type-less references to objects
    -Access control is different for data and methods
    -It is private for all data and cannot be changed
    -Methods can be either public, private, or protected
    -Method access is checked at runtime
    -Getters and setters can be defined by shortcuts
  80. 80(True/False) In Ruby, subclasses are subtypesFalse
  81. 81(True/False) In Ruby, access control to inherited methods can be different than in the parent classTrue
  82. 82What can be said about dynamic binding in Ruby?-All variables are typeless and polymorphic
  83. 83Overall what are some major evaluations of OOP in Ruby?-Does not support abstract classes
    -Does not fully support multiple inheritance
    -Access controls are weaker than those of other languages that support OOP
  84. 84What are 2 of the more challenging parts of implementing OO constructs-Storage structures for instance variables
    -Dynamic binding of messages to methods
  85. 85What is it that stores the state of an objectClass instance records (CIRs)
  86. 86If the CIRs (Class instance records) are static, when is it builtCompile time
  87. 87If a class has a parent, where are the subclass instance variables added?the parents CIR
  88. 88What is the storage structure for methods that will be dynamically bound (that must have entries in the CIR)?Virtual method tables
  89. 89This features in programming languages allows its programs to have runtime access to their types and structure and to be able to dynamically modifty their behaviorReflection
  90. 90This is the types and structure of a programmetadata
  91. 91What is the process of a program examining its metadata?introspection
  92. 92What is interceding in the execution of a program called?Intercession
  93. 93describe the uses of reflection for software tools-Class browsers need to enumerate the classes of a program
    -Visual IDEs use type information to assist the developer in building type correct code
    -Debuggers need to examine private fields and methods of classes
    -Test systems need to know all of the methods of a class
  94. 94What are some of the downsides of Reflection?-performance costs
    -Exposes private fields and methods
    -Some reflection code may not run under a security manager, making code nonportable

Information

Description
Social Issues and Ethics in CS Flashcards on Organization of Programming Langs Chapter 12, created by James Herd on 25/04/2019.
Created by
James Herd
Views
1
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?