Visit to a blind student's school🧑🦯🧑🦯(community medicine)
Module1 elementary concepts of objects and classes
1. QUICK REVISION GUIDE – THEORY PORTION
MODULE
ELEMENTARY CONCEPTS OF
OBJECTS AND CLASSES
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
3. Definition of a class in OOP
Definition of a class in the real world
Example of a classes and objects in the
real world
Format of defining a class
Attributes required for defining a class
members of a class
i) instance variable/member
variable/data member / fields
ii) class variable / static variable
iii) constructor
4. OBJECT
definition of object in the real world
Definition of object in OOP
Example of an object in the real world with
characteristics and behaviour
Characteristics / state of an object
Behaviiour of an object
format of object declaration
Format of object creation
memory allocation of an object
referencing members of a class using an object
representing real world objects in object
oriented programming
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
5. ABSTRACTION
Abstraction is the act of representing
essential features of a system without
including the background details or
explanations
Example of abstraction in the real world
Example of abstraction in OOP
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
6. ENCAPSULATION
The wrapping up of data and the related
functions into a single unit called class is
known as encapsulation.
Data hiding /Information hiding
preventing unauthorized accessing of data
from outside the class using the principle of
encapsulation and private access modifier is
called data hiding
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
7. INHERITANCE
Definition
Need for Inheritance
base class and derived class
Different forms of inheritance
- types of inheritance supported by
java
Use of key words extends and super
Function overriding
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
8. Definition
Inheritance is the process by which
a class acquires the properties of
another class.
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
9. Advantages of inheritance
help us to express inheritance
relationship which ensures
closeness with real-world
models
reusability of existing classes
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
10. Base class and Derived class
class A
base class
class B
derived class
base class is the class from which
properties are acquired. It is also called
super class or parent class
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
11. Base class and derived class
class A
base class
class B
derived class
derived class is the class that acquire
properties from another class. It is also
called sub class or child class or
extended class
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
12. Different forms of inheritance
single inheritance
class A
class B
A sub class inherits only from a base class
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
13. Different forms of inheritance
multilevel inheritance
class A
class B
a sub class
inherits from a
class that itself
inherits from
another class
class C
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
14. Different forms of inheritance
multiple inheritance
class A
class B
class C
a class is derived
from two or more
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
base classes
Applications Students
15. Different forms of inheritance
hybrid inheritance
class A
class B
class C
class D
a class acquires
properties from
another class
through two or more
paths
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
16. Different forms of inheritance
hierarchical inheritance
class A
class B
class C
class D
a class has
several sub
classes
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
17. Use of access modifiers in
Inheritance
private members of a class can
be used only with in the class
members of a class with default
access can be used with in the
class as well as in all the classes
with in the same package
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
18. Use of access modifiers in
Inheritance
protected members of a class can
be used with in the class, in a
class of the same package as
well as in a sub class. The sub
class may be in
the same package or in a
different package
public members of a class can be
used everywhere
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
20. POLYMORPHISM
Polymorphism comes from Greek
meaning “many forms.”
Polymorphism is the process by which
the same message can be given to
objects of different classes and each
object responds to this message in a
different manner depending on its class.
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
21. POLYMORPHISM
passing a message to an object is same as
calling a function using an object.
for e.g: String s1=s.substring(5,8);
In the above statement we invoke the
substring function of class string using the
object s1.
We can also say that we pass a message
substring to the object s1 with the values 5
and 8
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students
22. POLYMORPHISM
Function overloading can be considered
as an example of polymorphism
Binding
- dynamic binding or late binding
- static binding or early binding
Prepared by Merson Mathew, St. Joseph’s School Bhagalpur for ICSE Computer
Applications Students