0% found this document useful (0 votes)
5 views

oop final notes

The document outlines fundamental concepts of Object-Oriented Design (OOD) including information hiding, classes, objects, methods, and their interactions. It discusses the benefits of OOD such as reduced complexity, ease of maintenance, and reusability, along with specific programming terms like modifiers, constants, and method overloading. Additionally, it contrasts procedural and object-oriented paradigms, emphasizing the importance of encapsulation and inheritance in software design.

Uploaded by

amberlylbma-wm23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

oop final notes

The document outlines fundamental concepts of Object-Oriented Design (OOD) including information hiding, classes, objects, methods, and their interactions. It discusses the benefits of OOD such as reduced complexity, ease of maintenance, and reusability, along with specific programming terms like modifiers, constants, and method overloading. Additionally, it contrasts procedural and object-oriented paradigms, emphasizing the importance of encapsulation and inheritance in software design.

Uploaded by

amberlylbma-wm23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

CHAPTER 1 ii. Information hiding.

hide Variables defined in the public static void main(String[]


args) {
implementation from use method header
1. (OOD) problem solving System.out.println("netPay(88,
iii. reduce complexity 3. Modifier 14.50, 15%) = RM " +
process (flow)
iv. ease of maintenance Reserved words that specify Payroll.netPay(45, 9.50, 0.15));
a. Identify the objects for the
5. Constant the properties of the data,
problem System.out.println("netPay(88,
A variable whose value is methods and classes and 14.90) = RM " + Payroll.netPay(45,
b. Specify relevant data and
fixed and cannot be changed how they can be used 9.50));}
operations to be performed 5. Static variable
once it is assigned, typically 4. Method overloading
on that data Shared by all instances of
declared using the ‘final’ A situation where there are
c. Determine interactions the class and can be
keyword 2 or more method has the
between objects accessed using object name
a. Benefits same name but with a
2. Object or the class name[all objects
Easier to maintain, read, different parameter list. It
An instance of a class which affected if one changes
reduce error, consistency can be different datatype or
represents an entity in the value]
and better programming different number of
real world consisting unique 6. Static method
styles parameters. The compiler
state and behaviour Belong to class and can be
b. Syntax will determine which
3. Class invoked without the need for
<access modifier> final method to be execute based
A template or a blueprint creating an instance of a
<datatype> on the method signature.
that defines what an object’s class and can be accessed
<CONSTANT_NAME> = Method overloading allows
data field and method will directly in static and non-
<value> program to be more
be static methods
c. Example readable
4. Method
static final String a. Example
function or object CHAPTER 4
COLOR_CODE= #ff0000;
operations that is invoked on class Payroll {
public static double netPay(int 1. Procedural paradigm vs
an object to perform specific CHAPTER 2
hoursWorked, double payRate, object oriented paradigm
action double taxRate) {
a. Purpose return hoursWorked * PP OOP
payRate* (1 - taxRate); Data & Loosely Coupled
A method is a function that method coupled together
}
is used to perform a certain public static double netPay(int s into objects
operation when it is being hoursWorked, double payRate) { Softwar Designin Objects and
invoked by passing in data return hoursWorked * e design g operations
payRate* (1 - 0.15);
known as parameter } focus method on objects
1. Method signature } s
b. Benefit combination of the method } Data Separat Placed
i. Reusability. write once name and parameter list Public Class T2Q1 { and e, within a
and use it anywhere 2. Formal parameter operatio sending single
n data to entity(objec 5. Primitive data type ii. difficult to maintain and reference that refers to the
method t) Stores values directly to vulnerable to bugs calling object itself usually to
s stack memory d. Protected reference a class’s hidden
a. Example 8. Instance modifier data fields or to enable
Byte, short, int, long, float, Used when data is unique to constructor to invoke
2. Class
double, double, char, each instance of a particular another constructor of same
A class is a template for
boolean class(different values for class
objects. It defines the
6. Object data type different objects such as car, 13. overloading constructor
properties of the object, and
Stores address of object in model, year) two or more constructor
methods manipulating them.
heap memory. default value 9. Accessor(get) within same class but
A logical abstraction .
is null. If the object Read private properties parameter lists are
Defines what data to store
previously referenced no a. public returnType different(different number
and what actions we can getPropertyName()
longer referenced (garbage) or data types)
operate on the data b. public String getId(){
will be collected by JVM to return id;} a. Example
3. Constructor
be removed 10. Mutator(set) Circle(){
Constructor is a special radius=1.0;
7. Visibility modifiers Modify private properties
method used for initializing a. public void }
Restricting access to a class’s
objects when creating setPropertyName(dataT Circle(int r){
member radius=r;
objects using the new ype propertyValue)
a. Default b. public void setCredit(int }
operator.[ has same name as
class, variable or method c){ CHAPTER 5
class name and no explicit
can be accessed by class in creditHours = c;} 1. String
return type]
the same package(folder) 11. Encapsulation Sequence of characters
a. Purpose
b. Public Binds together code and the a. String message
i. give initial values to
class, data, or method is data it manipulates to keep = “Welcome”;
instances variables defined
visible to any class in any data and code safe from b. String variable
by the class
package external inference and holds a
ii. perform any other startup
c. Private misuse. code, data or both reference to a
procedures required to
Data or methods can be within an object may be string object
create fully formed object
accessed only by the private or public that stores a
4. Default constructor
declaring class. client a. Benefit string value
A no-arg constructor with an
retrieve and modify by using i. links data with the code c. Its content can't
empty body that is implicitly
accessor and mutator that manipulates it be
declared in the class if no
methods ii. provide means by which changed(immut
constructor is explicitly
to avoid:- access to members can be able)
declared in the class
i. data may be tampered controlled 2. String comparisons
Circle(){}
12. This keyword
a. For same 1. Subclass (child) – Methods of same name instance of
content = inherits data and to behave differently superclass to a
If(s1.equals(s2)) methods of within a class family reference
; return true superclass(parent) a. Runtime: variable of its
b. For same a. Denoted with overridden subclass
reference = extends method without an
If(s1==s2) ; keyword; resolved at explicit casting
return true subclass runtime using compilation
c. Check content = extends method error; use
if(s1.compareTo superclass overriding explicit casting
(s2)>0) ; any b. Private data b. Compile time: 6. Accessibility
comparison field of function or
symbol ; superclass not operator
returns integer accessible overloading
3. Retrieve and combine c. Superclass c. Benefit: easy to
length(),charAt(index),c constructor not maintain and
oncat(Stringname),subs inherited extensible
tring(start index,index d. Invoked design, add 7. Final modifier
end) superclass using class with Final local variable is a
4. Convert to String super(); minimum or no constant inside a
String.valueOf(5.44) , keyword modification, method
String.valueOf(c) 2. Benefit of inheritance superclass final double PI=3.142;
5. String builder vs buffer a. Reuse code sharing, CHAPTER 7
b. Build Class simplifies
StringBuilder String buffer 1. Abstraction
hierarchy programming
Single task Can be Process of simplification by
3. Method overriding 5. Casting
accessed by
When a method in a. Implicit casting removing characteristics
multiple task
subclass has same double x =9; from something to reduce it
concurrently
return type and Object 0 = new to a set of essential
More efficient Less efficient
Non- Synchronized; signature as a method Student(); characteristics.
synchronized; two threads in its superclass, it b. Explicit casting 2. Abstract method
two threads can can't call this override it. Int y = (int) x; Seperating the use of
call this method method a. Private method Student b = method from its
simultaneously simultaneously can’t be (Student)o; implementation.Exist within
overridden c. Downcasting : abstract classes
CHAPTER 6 4. Polymorphism assigning a. Indicator: # sign
b. Methods : italicized implement Abstract implements college won't
c. Constructor: constructor Invoked by No function
protected subclasses constructor a. Becomes weak is-a
d. Method signature When? Share Share when using interface
without common common
implementation code among behaviour
2. Aggregation
3. Advantages of abstract related among
classes instances a. Whole-part
methods relationship. One or 6. Class design guidelines
and
a. Ensures more relationship. Cohesion: describe single
unrelated
implementation by Not dependent. entity, consistency: follow
classes
subclasses One or Can inherit More than College remain if java programming style and
b. Can invoke abstract many 1 superclass one student is removed naming convention,
methods in interface encapsulation, clarity: easy
parameters of to explain and understand,
superclass completeness, instance vs
4. Interfaces 6. Wrapper classes 3. Dependency static, inheritance vs
Class-like construct contains Enables program process Relationship between two aggregation, interfaces vs
only constants and abstract primitive values as objects classes(uses one another). abstract
methods a. Contains number Weak relationship.loosely 7. Packages
a. Public interface class: doubleValue, coupled Used to Organize classes
InterfaceName{ floatValue, int Value, a. Reasons: Locate
Constant longValue, classes, avoid
declarations; shortValue, and naming conflicts,
Method signatures;} byteValue 4. Association distribute software
b. Name and method b. Provide a. Stronger than conveniently, protect
italicized and dashed constructors, dependency. The cases
line used to point to constants and state of object 8. Singleton pattern
interface conversion methods change when Restrict instantiation of class
5. Interface vs abstract for manipulating associated object to exactly one object
various data types change 9. Creating an immutable class
Abstract Interface
CHAPTER 8 a. Declare all data
variable Static & Static and
fields private, No
non-static final 1. Compositions mutator, No
Access all public a. Strong ownership. 5. Inheritance
modifier accessor
Dependent. If Strong is-a relationship
speed fast slow
student is removed,

You might also like