Sunteți pe pagina 1din 4

OOAD HOMEWORK 1:

1. What are the four basic principles of object orientation? Provide a brief
description of each:

- Encapsulation:

Encapsulation is the mechanism of hiding of data implementation by restricting


access to public methods. Instance variables are kept private and accessor
methods are made public to achieve this.

- Abstraction:

Abstract means a concept or an Idea which is not associated with any particular
instance. Using abstract class/Interface we express the intent of the class rather
than the actual implementation. In a way, one class should not know the inner
details of another in order to use it, just knowing the interfaces should be good
enough.

- Inheritance:

Inheritances expresses “is-a” and/or “has-a” relationship between two objects.


Using Inheritance, In derived classes we can reuse the code of existing super
classes. In Java, concept of “is-a” is based on class inheritance or interface
implementation

- Polymorphism:

It means one name many forms. It is further of two types — static and dynamic.
Static polymorphism is achieved using method overloading and dynamic
polymorphism using method overriding. It is closely related to inheritance. We
can write a code that works on the superclass, and it will work with any subclass
type as well.

2. What is an object and what is a class?


What is the difference between the two?
- A class is a description of a set of objects that share the same attributes,
operations, relationships, and semantics.
- An object acts as member or instance of that class.
- The difference between the two:
Class Object
A class is a blueprint from which you An object is the instance of the class,
can create the instance which helps programmers to use
variables and methods from inside the
class.

A class is used to bind data as well as Object acts as a variable of the class.
methods together as a single unit.
Classes have logical existence. Objects have a physical existence.

A class doesn't take any memory spaces An object takes memory when a
when a programmer creates one. programmer creates one.

The class has to be declared only once. Objects can be declared several times
depending on the requirement.

3. What is an attribute?
- An attribute is a named property of a class that describes a range of
values that instances of the property may hold.

4. What is an operation?

- An operation is the implementation of a service that can be requested from


any object of the class to affect behavior.

5. What is polymorphism? What is an interface?

- Polymorphism is a concept that refers to the ability of a variable, function


or object to take on multiple form.
- Interface:
o Interfaces formalize polymorphism
o Interfaces support “plug and play” architectures

6. What is a package?

- A package is a general-purpose mechanism for organizing elements into


groups.
- It is a model element that can contain other model elements.
- A package can be used:
o To organize the model under development.
o As a unit of configuration management.

7. What is a subsystem? How does it relate to a package? How does it relate to a


class?
- Subsystem :
+ A combination of a package (can contain other model elements) and a
class (has behavior).
+ Realizes one or more interfaces which define its behavior.
- Relate to a package:
A package is a grouping and organizing element in which other element
resides, which must be uniquely named. In the UML, packages are used in
the manner similar to the way directories and folders in an operating
system group and organize files.
- Relate to a class:
Each class belong to exactly one subsystem. Classes are related to classes in
other subsystems.

8. Name the four basic UML relationships and describe each:

- Dependency: is a semantic connection between dependent and independent -


model elements

- Association: represents a family of links

- Aggregation: is a variant of the "has a" association relationship; aggregation is


more specific than association

- Multiplicity: The number of instances one class relates to ONE instance of


another class. For each association, there are two multiplicity decisions to make,
one for each end of the association.

9. Describe the strengths of object orientation:

- Provides a clear modular structure for programs.


- Objects can also be reused.
- Makes software easier to maintain.
- Reuse also enables faster development.
- Provides a good framework for code libraries where the supplied software
components can be easily adapted and modified by the programmer.
- Better productivity.
10. What are stereotypes?
- Stereotype is a profile class which defines how an existing metaclass
may be extended as part of a profile. It enables the use of a platform or
domain specific terminology or notation in place of, or in addition to, the
ones used for the extended metaclass.

S-ar putea să vă placă și