Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

Unit 20 Advance Programming

Nyi Min Khant


21 Batch 1
YOUTH International University
Encapsulation in Java 2

• Encapsulation in Java is a process of wrapping code and data


together into a single unit, for example, a capsule which is mixed
of several medicines.
• 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.
Inheritance 3

• Inheritance in Java is the method to create a hierarchy between


classes by inheriting from other classes. Java Inheritance is
transitive - so if Sedan extends Car and Car extends Vehicle, then
Sedan is also inherited from the Vehicle class. The Vehicle
becomes the superclass of both Car and Sedan
Abstraction 4

• Abstraction is a process of hiding the


implementation details and showing only
functionality to the user. Another way, it
shows only essential things to the user and
hides the internal details, for example,
sending SMS where you type the text and
send the message.
Polymorphism 5

• In Java, polymorphism refers to the ability of a class to provide


different implementations of a method, depending on the type of
object that is passed to the method. To put it simply,
polymorphism in Java allows us to perform the same action in
many different ways.
Dependency 6

• Dependency Injection in Java is a way to achieve Inversion of


control (IoC) in our application by moving objects binding from
compile time to runtime. We can achieve IoC through Factory
Pattern, Template Method Design Pattern, Strategy Pattern and
Service Locator pattern too.
Association 7

• Association in Java is a connection or


relation between two separate classes that
are set up through their objects.
Association relationship indicates how
objects know each other and how they are
using each other's functionality. It can be
one-to-one, one-to-many, many-to-one and
many-to-many.
Composition 8

• A composition in Java between two objects associated with each


other exists when there is a strong relationship between one class
and another. Other classes cannot exist without the owner or
parent class. For example, A 'Human' class is a composition of
Heart and lungs.
Generalization 9

• Generalization is the process of taking out common properties and


functionalities from two or more classes and combining them
together into another class which acts as the parent class of those
classes or what we may say the generalized class of those
specialized classes. All the subclasses are a type of superclass. So
we can say that subclass “is-A” superclass. Therefore
Generalization is termed as “is-A relationship”
Realization 10

• In UML modeling, the realization is a relationship between two


objects, where the client (one model element) implements the
responsibility specified by the supplier (another model element).
The realization relationship can be employed in class diagrams and
components diagrams.

• The realization relationship does not have names. It is mostly


found in the interfaces. It is represented by a dashed line with a
hollow arrowhead at one end that points from the client to the
server.
Multiplicity 11

• In Java, the multiplicity between objects is defined by the


Association. It shows how objects communicate with each other
and how they use the functionality and services provided by that
communicated object. Association manages one-to-one, one-to-
many, many-to-one and many-to-many relationships.
Constructors / Destructors 12

• In object oriented programming, both constructor and destructor


are the member functions of a class having the same name as the
class. A constructor helps in initialization of an object, i.e., it
allocates memory to an object. On the other hand, a destructor
deletes the created constructor when it is of no use which means
it deallocates the memory of an object.

• In this article, we will discuss the important differences between


constructors and destructors. Let's start with some basic concepts
of constructors and destructors.
Constructors and Destructors 13

• The main difference between Abstract Class and Concrete Class is that it is not
possible to create objects using an abstract class while using a concrete class,
it is possible to create objects.

• Object-Oriented Programming (OOP) is a popular paradigm in software


development. It helps to develop a real-world scenario easily. Moreover, it also
allows programmers to model the software using a set of objects. These
objects communicate with other objects to pass messages. Furthermore, an
object is created using a class. A concrete class is a default class. One major
pillar in OOP is Abstraction. Abstract class is a method of achieving abstraction.
Method redefinition 14

• Method overriding in Java means redefining a method in a subclass


to replace the functionality of superclass method.

• When the method of superclass is overridden in the subclass to


provide more specific implementation, it is called method
overriding.
Generics and Templates 15

• Templates are the foundation of generic programming, which


involves writing code in a way that is independent of any
particular type. A template is a blueprint or formula for creating a
generic class or a function
Containers 16

• Containers are the interface between a component and the low-


level, platform-specific functionality that supports the
component. Before it can be executed, a web, enterprise bean, or
application client component must be assembled into a Java EE
module and deployed into its container.

You might also like