Programming: Object Oriented Programming: Object-Oriented Programming (OOP) Is A
Programming: Object Oriented Programming: Object-Oriented Programming (OOP) Is A
Programming: Object Oriented Programming: Object-Oriented Programming (OOP) Is A
★★Cocomo model---৩৫/৩৬/৩৭
★★TDM---৩৫/৩৭
★★Digital signature, public key & private key eencryption কীভাবে কাজ করে---৩৫/৩৬/৩৭
Programming
OOP Principles: There are total four OOP principles which are given below.
1. Encapsulation: Encapsulation is the mechanism that binds together code and the
data it manipulates, and keeps both safe from outside interference and misuse. In
encapsulation, the variables of a class will be hidden from other classes, and can be
accessed only through the methods of their current class. Therefore, it is also known
as data hiding.
2. Inheritance: Inheritance is the process where one object acquires the properties
(methods and fields) of another objects. With the use of inheritance the information is
made manageable in a hierarchical order. The class which inherits the properties of
other class is known as subclass (derived class, child class) and the class whose
properties are inherited is known as superclass (base class, parent class).
Constructor: A constructor initializes an object immediately upon creation. It has the same
name as the class in which it resides and is syntactically similar to a method. Once defined,
the constructor is automatically called when the object is created, before the new operator
completes. Constructors look a little strange because they have no return type, not even
void. This is because the implicit return type of a class constructor is the class type itself.
Copy Constructor: The copy constructor is a constructor which creates an object by initializing it
with an object of the same class, which has been created previously. The copy constructor is used to −
● Initialize one object from another of the same type.
● Copy an object to pass it as an argument to a function.
● Copy an object to return it from a function.
If a copy constructor is not defined in a class, the compiler itself defines one. The most common form
of copy constructor is shown here −
Destructor: Destructors are the concept of object oriented programming. Constructors are
called when the object is created, and the destructor is called when the object is erased. A
object is by the way like a clone of a class. That way there can be several objects or
instances of a class. In Java, programmers don’t need to worry about destructors. There is
no syntax for destructors in java. Objects are destructed but there is no destructor. The Java
Virtual Machine handles that for you. In other languages like c++ or c# you can also write a
destructor but not in java. In C++ you write a destructor like a constructor but with a ~ before
the name.
Abstract Class: An abstract class is a class that contains one or more abstract methods. An
abstract method is a method that is declared, but contains no implementation. Abstract
classes may not be instantiated, and require subclasses to provide implementations for the
abstract methods. An abstract method of a superclass must be implemented by the
subclass.
Multithreaded Programming: A multithreaded program contains two or more parts that can
run concurrently. Each part of such a program is called a thread, and each thread defines a
separate path of execution. Thus, multithreading is a specialized form of multitasking.
Thread Example:
● By extending Thread Class:
Method Overriding: Overriding is a feature that allows a subclass or child class to provide a
specific implementation of a method that is already provided by one of its superclasses or
parent classes.
Access Modifiers: Access modifiers (or access specifiers) are keywords in object-oriented
languages that set the accessibility of classes, methods, and other members.
There are total four types of access modifiers.
Friend Function: A friend function of a class is defined outside of that class scope but it has
the right to access all the private and protected members of the class. Even though the
prototypes for friend functions appear in the class definition, friends are not member
functions.
A friend can be a function, function template, or member function, or a class or class
template, in which case the entire class and all of its members are friends.
Recursion: Recursion is the process of repeating items in a self-similar way. In
programming languages, if a program allows you to call a function inside the same function,
then it is called a recursive call of the function.