Answers to Final Exam

  1. A class is a set of methods and data items combined in a single entity. It provides some service or does some work and serves as a functionality package.

  2. An object is an instance of a class. A class is essentially a data type, and an object is a variable of that data type.

  3. An attribute or property is a piece of data in a class. It has a value at any given time and may be readable, writable, or both.

  4. Object behavior defines how an object works under certain operations.

  5. Attibutes: Suit, Value, FaceUp
    Methods: GetSuit, SetSuit, GetValue, SetValue, IsFaceUp, Flip

  6. Inheritance means that a class is based upon the methods and attributes of an existing class.

  7. Code reuse

  8. Vehicle, because a minivan is a vehicle ”the minivan is derived from vehicle.

  9. Engine and Diesel, because Diesel is a type of engine. A Car has a(n) engine, which describes containment, not inheritance.

  10. A business object is a class used by a business system or application, such as an order form.

  11. A characteristic is an attribute or method that distinguishes two classes.

  12. A class definition defines attributes and methods that are members of the class.

  13. An argument list is a list of data items passed to a method or function for it to do its job.

  14. A return value is a value that a method returns as its output or result. Return values are optional.

  15. Engine anEngine = new Engine();

  16. Engine anEngine;

  17. A constructor is a special method that initializes the attributes of a class.

  18. A destructor is a special method that releases any resources (such as memory) from an object instance. Java does not implement true destructors, while C++ does because Java performs garbage collection while C++ doesn t (and garbage collection is not guaranteed to run before the program terminates).

  19. Garbage collection is the ability of a language to automatically remove objects created in memory when the last reference or use of the object goes out of scope or is no longer needed.

  20. In Java, C++, and C#, you use the dot (.) operator. C++ also uses the arrow (->) operator if you have a pointer to an object.

  21. Encapsulation is the grouping of concepts or behaviors into a class. It defines how the class behaves, without offering details as to how it implements that behavior.

  22. Polymorphism means that something has many shapes and that something is a method of an object-oriented programming language. In programming terms, a thing is the name of a method and a shape is the behavior performed by a method. Polymorphism means that one or more methods with the same name exist for many behaviors.

  23. Overloading is another one of those terms you hear used in conjunction with polymorphism. Overloading means that two or more methods are defined using the same name, but with different argument list.

  24. Binding is the association of a method definition (or function body) with a call to a method, and occurs either at compile time or at runtime. Compile-time or Early binding is used for normal method calls. No time is lost when the program runs because binding is completed when the executable program is created. Runtime or Late binding is implemented using a virtual function, which uses a base reference to point to the type of object that contains the correct method definition.

  25. Run-time polymorphism uses virtual functions to create a standard interface and to call the underlying functions. Those function definitions are bound to function calls during run time.

  26. A virtual function is used to trick the computer into thinking a function is defined, but the function doesn t have to be defined at that moment. Instead, the virtual function can be a placeholder for the real function that is defined in a program. Virtual functions help support run-time polymorphism.

  27. Use the keyword virtual in the declaration of the method, such as Foo :

     class Boo { 
    virtual void Foo();
  28. Methods are virtual in Java and C# by default. To create a virtual method without any body in these languages, use the abstract keyword in the declaration of the method.

  29. Method Overloading is a technique to implement polymorphism by defining two or more methods with the same name but different argument list.

  30. Public members are seen by all methods, even ones outside the class. Protected members are seen only to that class and ones derived from it. Private members are seen only by that class, and nothing else.

  31. Simple inheritance occurs when there is one parent-child relationship ”that is, one child inherits from one parent.

  32. Multiple inheritance is where there is a multiple parent-child relationship. The child inherits from more than one parent. Java and C# do not support multiple inheritance, but C++ does.

  33. It describes a situation where a single base class (such as Person ) contains a data member such as Name , and then two classes are derived from it such as Student and Instructor . Now that Student and Instructor contain a Name member, if we were to create a new class derived from both (such as a TeachingAssistant class), then the object could have two names for what is really one person.

  34. Level inheritance happens when a child inherits from a parent and then becomes a parent itself to a child.

  35. There is no practical limit ”if you find a compiler that can t handle 1,000 levels of inheritance, the real problem is that you have a poor design because there are too many levels of inheritance. A rule of thumb is to try and limit things to three levels.

  36. C++ typically uses the terms base class and derived class, while Java typically uses super class and subclass.

  37. Abstraction is a way a programmer of a super class forces a programmer of a subclass to define a behavior.

  38. Programmers distinguish a behavior from instructions used to perform the behavior using the term s functionality and function.

  39. An abstract method does not provide a method body. A class with an abstract method requires derived classes to implement the method body. A class with an abstract method is called an abstract class. Abstract methods are called pure virtual methods in C++.

  40. An abstract class is one that has one or more abstract methods. Because of this, you cannot instantiate an object of this type. You must create a derived class that provides the method bodies for the abstract methods, and then you can instantiate the derived class.

  41. Object-oriented programmers decompose each attribute into data and then use data in the corresponding class definition to describe the object. Decomposition is the technique that reduces an attribute into its data components .

  42. An iconic description is a graphic picture of the process. Textual description describes the process in words.

  43. Pseudo code is a combination of English words and programming language syntax that describe in words how a process works. The result is not entirely English, nor a syntactically correct program. It s used to enforce understanding and requirements without actually writing a program.

  44. An entity refers to an individual item, and may be a single piece of data or an object.

  45. Entity relationship (or functional relationship) describes how objects are related or interact with one another.

  46. It defines a relationship between two different types (such as Student and Course) where any single first type (Student) can be related to 1 or more of the second type (Course), and vice versa. For example, one student may be registered in many courses, and a course may have many students.

  47. A leveling diagram depicts an application in layers where the top level has the least amount of detail and is the easiest to understand. Subsequent levels have more detail and are usually the hardest to understand.

  48. A class diagram is an illustration that describes a class, its attributes, and its behaviors.

  49. The internal model describes how an application works behind the scenes.

  50. The external model describes how a person interacts with the application.

  51. The is a test asks the question is object A a type of object B. If so, then object A can inherit object B. For example, a Minivan is a type of Vehicle, so Minivan can be derived from Vehicle.

  52. The has a test asks the question does object A have an object B. If so, then object A would have a data member of type Object B. For example, a Vehicle has an Engine, so a Vehicle object would have an Engine object as a data member.

  53. Collaboration occurs when two or more things work together or cooperate with each other in order to achieve a common goal. In programming, it means that one class might have methods that call methods from another class.

  54. UML stands for Unified Modeling Language, and is a set of diagramming and text standard to help define a process and classes involved in the process.

  55. A Sequence diagram is a diagram that shows the typical sequence of events for a process.

  56. Collaboration diagrams are used to display basic interaction between classes.

  57. When discussing collaboration, we typically say that a class collaborates with another via a Message. Technically, a message is a function call, so if we say that class A sends a message to class B, we are saying that class A is calling a method in a class B object.

  58. Association means that the two classes need to know how to interact with one another, and is part of the description of collaboration.

  59. Self-collaboration is when a class invokes its own methods.

  60. The Class Responsibility Collaborator (CRC) diagram is intended to be an all-inclusive list of how a single class is to be designed. A CRC diagram lists the class name at the top, and then two columns below for responsibilities and collaborators.

  61. An actor is a person, organization, or anything that might interact with a system. Actors don t need to be persons. If a system needs to output a file in a certain format for a government agency, then that agency might be considered an actor as well.

  62. An SME (Subject Matter Expert) is a person who has intimate knowledge about the work or process for which you are developing a system. They don t need to have any computer experience.

  63. An Essential Use Case is a nontechnical view of how your system will work with its users.

  64. A System Use Case defines the technical view of how your system will work.

  65. Business Rules are the rules and laws that govern how a business operates. An SME is typically the most accurate source of business rules.

  66. User Interface Diagrams are prototypes or designs for a programs user interface. It may contain forms and controls, as well as menu items.

  67. User Interface-Flow diagrams let you define the flow of the program in terms of the user interface, such as the steps a user must take to perform some process.

  68. A Change case represents possible or definite changes to a system. The goal of the change case is to design a flexible system and anticipate possible or definite changes so that the system can be designed to be easily adaptable.

  69. An interface represents a set of standard methods to provide some behavior or feature to a class. For a class to have some certain behavior, it declares that it will implement the interface that defines the behavior.

  70. Client ”Entity for which the work is being done.

    Project ”The definition of the project and the group for the remaining items. Clients can have multiple projects.

    Work Request ”Identifies a request, feature, change, or bug report. Projects are made up of requests and features initially, and then as time goes on features, changes, and bug reports are added.

    Task ”The work performed by the entity developing the project. Tasks are the work performed to complete a Work Request.

  71. Failure of a programmer to define an abstract method in a subclass, an attempt by the programmer to call the super class s abstract method, and an attempt to declare an instance of the abstract super class in the program.

  72. A framework is a set of classes or class library that has been designed to work well together and that follows a certain paradigm.

  73. Objects that are very reusable across different applications (like a string class or stream hierarchy), objects that are reusable within a particular set of programs (like a student class and hierarchy for academic institution programs), and objects that simply will never be reused again anywhere .

  74. Objects are thought of as nouns (person, place, or thing). Tasks are thought of as verbs because they describe action within an application.

  75. A hierarchy is morphed when a member function has many versions of a behavior requiring many overloaded functions.

  76. Multiple inheritance should be used whenever a child needs to inherit attributes and behaviors from parents that are not related to each other.

  77. Early binding is the binding of a method call to a method definition and is performed at compile time if all the information is available at compile time.

  78. Late binding is the binding of a method call to a method definition and is performed at run time. It implicitly makes use of base class pointers or references to derived objects, and methods must be virtual.

  79. No. Unlike flow charts , Sequence diagrams do not show flow control; they show sequence.

  80. It represents the pseudo-destructor for a class. If garbage is collected, the finalize method is called, but there is no guarantee when or even if this will occur.

  81. Nonstatic data members occur in each instance of the class and nonstatic methods can work with them as well as static methods. Static data members occur only once no matter how many instances of a class and static methods can only work directly with static data members. You do not need to declare an instance of a class to use its static methods or properties.

  82. public class Derived extends Base { ...

  83. class Derived : public Base { ... // public may also be private or protected.

  84. class Derived : Base { ...

  85. It means that no class can be derived from it.

  86. It is compiled into bytecode, and then the Java Virtual Machine interprets the byte code.

  87. It is compiled into native machine code.

  88. It is compiled into byte code, and then the CLR recompiles it into native machine code.

  89. C++

  90. Java, since its bytecode can be used without recompiling. C# and the CLR are designed for this ability, but only currently available on Windows Desktop and Windows Mobile operating systems.

  91. Garbage collection releases the programming from the task of manually releasing memory. The disadvantage is that garbage collection systems are unpredictable as to when they release memory and may require manual coding to do so.

  92. C++, which supports pointers directly to memory. C# includes some support for memory access and Java provides none.

  93. Java and C#. C++ can mimic this behavior by defining an abstract class and using multiple inheritance.

  94. C++ and Java version 1.5

  95. J2EE ”Java Enterprise Edition for servers, J2SE ”Java Standard Edition for desktops, and J2ME ”Java Micro Edition for handheld devices.

  96. The JVM, or Java Virtual Machine, is the program that must be installed on a computer in order to interpret and execute the compiled byte code of a Java program.

  97. The CLR, or Common Language Runtime, is the program that must be installed on a computer in order to interpret and compile the bytecode generated by compiling a C# program.

  98. C++, because it doesn t require a JVM or CLR to be in memory while it runs.

  99. ENIAC, built in the mid-1940s

  100. Grace Hopper coined the term when she found a moth stuck between some tubes, which was causing her program to act incorrectly.

OOP Demystified
OOP Demystified
ISBN: 0072253630
EAN: 2147483647
Year: 2006
Pages: 130

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: