ICS2602: Module 11 OOP

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/119

120 Terms

1
New cards
Object-Oriented Programming
is a computer programming model that organizes software design
around data, or objects, rather than functions and logic. An object can be defined as a data field that has unique attributes and behavior.
2
New cards
object
a software bundle of related state
and behavior. Software objects are often used to model the real-world objects that you find in everyday life
3
New cards
Parts of an OBJECT
Attributes and Methods
4
New cards
Benefits of Bundling Code into Individual Software Object
Modularity, Information-hiding, Code re-use, and Pluggability and Debugging Ease
5
New cards
Modularity
The source code for an object can be written and maintained
independently of the source code for other objects. Once created, an object can be easily passed around inside the system.
6
New cards
Information-hiding
By interacting only with an object's methods, the details of
its internal implementation remain hidden from the outside world
7
New cards
Code re-use
If an object already exists (perhaps written by another software
developer), you can use that object in your program. This allows specialists to implement/test/debug complex, task-specific objects, which you can then trust to run in your own code.
8
New cards
Pluggability and debugging ease
If a particular object turns out to be problematic, you can simply remove it from your application and plug in a different object as its replacement. This is analogous to fixing mechanical problems in the real world. If a bolt breaks, you replace it, not the entire machine.
9
New cards
class
blueprint or prototype from which objects
are created.
10
New cards
class
This section defines a class that models the state and behavior of a real-world object.
11
New cards
class
It intentionally focuses on the basics, showing how even a simple class can cleanly model state and behavior.
12
New cards
class diagram
depicts a static view of an application
13
New cards
class diagram
It represents the types of objects residing in the system and the relationships between them.
14
New cards
class diagram
A class consists of its objects, and also it may inherit from other classes.
15
New cards
class diagram
used to visualize, describe, document various different aspects of the system, and also construct executable software code.
16
New cards
Components of a Class Diagram
Upper, Middle, and Lower Section
17
New cards
Upper Section
encompasses the name of the class
18
New cards
class
a representation of similar objects that shares
the same relationships, attributes, operations,
and semantics
19
New cards
capitalize
? the initial letter of the class
name
20
New cards
center
Place the class name in the ? of the
upper section.
21
New cards
bold
(class diagram sections) A class name must be written in ? format.
22
New cards
italics
(class diagram sections) The name of the abstract class should be written in ? format
23
New cards
Middle Section
(class diagram sections) constitutes the attributes, which describe the quality of the class
24
New cards
symbol for PUBLIC in class diagram
+
25
New cards
symbol for PRIVATE in class diagram
-
26
New cards
symbol for PROTECTED in class diagram
#
27
New cards
symbol for PACKAGE in class diagram
~
28
New cards
true
The accessibility of an attribute class is
illustrated by the visibility factors.
29
New cards
true
A meaningful name should be assigned to
the attribute, which will explain its usage
inside the class.
30
New cards
Lower Section
(class diagram sections) contain methods or operations
31
New cards
Lower Section
(class diagram sections) The methods are represented in the form of a list, where each method is written in a single line.
32
New cards
Lower Section
(class diagram sections) It demonstrates how a class interacts with data.
33
New cards
Types of Relationships
Dependency, Generalization, Association, Multiplicity, Aggregation, and Composition
34
New cards
Dependency
Dependency
(types of relationships) a semantic relationship between two or more classes where a change in one class cause changes in another class. In the following example, Student_Name is dependent on the Student_Id.
35
New cards
Dependency
(types of relationships) It forms a weaker relationship.
36
New cards
Generalization
Generalization
(types of relationships) a relationship between a parent
class (superclass) and a child class (subclass). In this, the child class is inherited from the parent class.

For example, The Current Account, Saving Account, and Credit Account
are the generalized form of Bank Account.
37
New cards
Association
Association
(types of relationships) It describes a static or physical connection between two or more objects. It depicts how many objects are there in the relationship.


For example, a department is associated with the college.
38
New cards
Multiplicity
Multiplicity
(types of relationships) It defines a specific range of allowable instances of attributes. In case if a range is not specified, one is considered as a default multiplicity.

For example, multiple patients are admitted to one hospital.
39
New cards
Aggregation
Aggregation
(types of relationships) is a subset of association, which represents
has a relationship.
40
New cards
Aggregation
(types of relationships) It is more specific than association. It defines a part-whole or part-of relationship.
41
New cards
Aggregation
Aggregation
(types of relationships) In this kind of relationship, the child class can exist independently of its parent class. The company encompasses a number of employees, and even if one employee resigns, the company still exists.
42
New cards
Composition
Composition
(types of relationships) is a subset of aggregation.
43
New cards
Composition
Composition
(types of relationships) It portrays the dependency between the parent and its child, which means if one part is deleted, then the other part also gets discarded. It represents a whole-part relationship.

A contact book consists of multiple contacts, and if you delete the contact book, all the contacts will be lost.
44
New cards
true
In the abstract class, no objects can be a direct entity of
the abstract class.
45
New cards
abstract class
can neither be declared nor be instantiated
46
New cards
abstract class
abstract class
used to find the functionalities across the classes

The notation of the abstract class is similar to that of class; the only difference is that the name of the CLASS IS WRITTEN IN ITALICS
47
New cards
true
best to use the abstract class with multiple objects
48
New cards
Class Diagram
used most widely to construct software applications
49
New cards
Class Diagram
It not only represents a static view of the system but also all the major aspects of an application.
50
New cards
Class Diagram
A collection of class diagrams as a whole represents a system.
51
New cards
meaningful
(class diagram key points) To describe a complete aspect of the system, it is suggested to give a ? name to the class diagram.
52
New cards
advance
(class diagram key points) The objects and their relationships should be acknowledged in ?.
53
New cards
methods
(class diagram key points) The attributes and ? (responsibilities) of each class must be known.
54
New cards
specified
(class diagram key points) A minimum number of desired properties should be ? as more number of the unwanted property will lead to a complex diagram.
55
New cards
describe
(class diagram key points) Notes can be used as and when required by the developer to ? the aspects of a diagram.
56
New cards
redrawn
(class diagram key points) The diagrams should be ? and reworked as many times to make it correct BEFORE PRODUCING its final version
57
New cards
public class Person
{
public String name;
public int age;
public void showDetails()
{code}
}
public class Person
{
public String name;
public int age;
public void showDetails()
{code}
}
Type the equivalent code:
58
New cards
Constructor
a method-like construct that has the same name as your class
name
59
New cards
false
Constructors DOES have any return type, even void.
60
New cards
true
(true of false) There is always at least ONE constructor for each class, if the writer does not provide a constructor, Java will provide the default, no-argument, empty-bodied constructor.
61
New cards
Constructor's Golden Rule
There is always at least one constructor for each class, if the writer does not provide a constructor, Java will provide the default, no-argument, empty-bodied constructor.
62
New cards
this
Java Keyword: this is a reference variable that refers to the current object.
63
New cards
current
(usage of 'this' keyword) this can be used to refer ? class instance variable
64
New cards
class method
(usage of 'this' keyword) this can be used to invoke current ? (implicitly)
65
New cards
constructor
(usage of 'this' keyword) this() can be used to invoke current class ? .
66
New cards
passed
(usage of 'this' keyword) this can be ? as an argument in the method call.
67
New cards
constructor
(usage of 'this' keyword) this can be passed as argument in the ? call.
68
New cards
return
(usage of 'this' keyword) this can be used to ? the current class instance from the method.
69
New cards
instance method
called thru the created object
70
New cards
static method
is called thru the class name
71
New cards
Integer class
found under the java.lang package and has a static method
parseInt() that can accept an String integer format that will return an int value.
72
New cards
Integer.parseInt(strNum);
Since the parseInt() method is static, then we call the method thru the name of the class, ? .
73
New cards
Encapsulation, Inheritance, and Polymorphism
Object Oriented Programming Language supports
three main features:
74
New cards
Encapsulation
(OOP 3 main features) Allows you to protect your data from direct access
75
New cards
Encapsulation
(OOP 3 main features) It also provides a common interface that makes them accessible and guards the state of your data by checking the correctness of the values assigned before applying the actual change.
76
New cards
Encapsulation
(OOP 3 main features) It also allows you to create methods that can be called later in your code and the users or callers of those methods need not worry on how the method was implemented.
77
New cards
Encapsulation
(OOP 3 main features) It also allows you to create methods that can be called later in your code and the users or callers of those methods need not worry on how the method was implemented.
78
New cards
Encapsulation
(OOP 3 main features) We can create a fully encapsulated class in Java by making all the data
members of the class private. Now we can use setter and getter
methods to set and get the data in it.
79
New cards
Encapsulation
(OOP 3 main features) EXAMPLE: Package, Access Modifiers
80
New cards
Java Source File Layout
Package – Import – Classes
81
New cards
number of statements per part in PACKAGE
0 to 1 statement
82
New cards
number of statements per part in IMPORT
0 to many
83
New cards
number of statements per part in CLASSES
0 to many
84
New cards
Packages
refer to subdirectories
85
New cards
Packages
may contain classes or sub-packages
86
New cards
Inheritance
(OOP 3 main features) way to reuse objects, carrying over what
was already created and allowing added methods and
attributes to be written on top of what you already have.
87
New cards
Inheritance
(OOP 3 main features) This useful feature allows programmers to reuse what was already coded and not making them rewrite codes and produce redundancies.
88
New cards
Inheritance
(OOP 3 main features) Reusing code can make the runtime of your application faster by eliminating duplicate codes.
89
New cards
class
(terms used in INHERITANCE) is a group of objects which have common properties. It is a template or blueprint from which objects are created.
90
New cards
sub/child class
(terms used in INHERITANCE) which inherits the other class. It is also called a derived class, or extended class
91
New cards
super/parent class
(terms used in INHERITANCE) class from where a subclass inherits the features. It is also called a base class
92
New cards
Reusability
(terms used in INHERITANCE) As the name specifies, reusability is a mechanism which facilitates you to reuse the fields and methods of the existing class when you create a new class. You can use the same fields and methods already defined in the previous class.
93
New cards
syntax of Java Inheritance
class Subclass-name extends Superclass-name
94
New cards
extends
(terms used in INHERITANCE) indicates that you are making a new class that derives from an existing class. The meaning of the term is to Increase the functionality.
95
New cards
Java Inheritance
Java Inheritance
name the example (OOP features)
96
New cards
Polymorphism
is another process that will allow you to change the method implementation during runtime by having a declared type of a certain class and implements the methods of the sub-type (subclass) also known as Virtual Method Invocation (VMI).
97
New cards
Polymorphism
EXAMPLE: Method Overloading, Method Overriding,
Covariant Return Type, Instanceof Operator, etc.
98
New cards
thread
a Virtual CPU (you may think of a virtual CPU as a virtual machine). It contains three things, the CPU (Thread Class), Code and the Data.
99
New cards
false
Java applications CANNOT run several threads.
100
New cards
Multi-threading
makes use of these three elements and creates its own independent runtime process inside a running Java Application. It is extremely useful in practice. For example, a browser should be able to simultaneously download multiple images while accessing other data storage devices or printing a document.