1. Hello!
We are Team
Quadra
Our Group members are:
Nafiz Ar Rafi (ID: 17182103359)
Shohana Iasmin (ID: 17182103322)
MD. Maruf Hossain (ID:
Sinthia Sayeed (ID:
Rokonuzzaman Razu (ID: 17182103211)
1
4. Features of OOP
Abstraction: In Java, abstraction means simple things
like objects, classes and variables represent more
complex underlying code and data. This is important
because it lets you avoid repeating the same work
multiple times.
Encapsulation: The practice of keeping fields within a
class private, then providing access to those fields via
public methods. Encapsulation is a protective barrier
that keeps the data and code safe within the class
itself.
Polymorphism: Allows programmers to use the same
word in Java to mean different things in different
contexts. One form of polymorphism is method
overloading. The other form is method overriding.
Inheritance: Inheritance is a special feature of Object-
Oriented Programming in Java that lets programmers
create new classes that share some of the attributes of
existing classes.
4
5. “
5
The simple abstraction example that is given above has a
class Car. In this class Car, we have an abstract method to
accelerate (). Then we inherit this class in the Suzuki class.
Inside the Suzuki class, we implement the accelerated
method.
Example of Abstraction
7. 7
Example of Polymorphism
In this example, we are creating two classes Bike and Splendor. Splendor class
extends Bike class and overrides its run() method. We are calling the run method by
the reference variable of Parent class. Since it refers to the subclass object and
subclass method overrides the Parent class method, the subclass method is invoked at
runtime
8. Example of Inheritance
8
In the above example, Programmer object can access the field of own class as
well as of Employee class.
10. What are the Access
modifiers?
We can change the access level of fields,
constructors, methods, and classes in Java
programs by applying the access modifier to
them. The access level refers to the
accessibility or scope of a field, method,
constructor, or class.
10
Access
Modifi
er
11. There are four types of java access
modifiers
11
Private modifier: The access level of a private modifier is only within the class. It cannot be accessed from outside
the class.
Default modifier: The access level of a default modifier is only within the package. It cannot be accessed from
outside the package. If you do not specify any access level, it will be the default.
Protected modifier: The access level of a protected modifier is within the package and outside the package through
child class. If you do not make the child class, it cannot be accessed from outside the package.
Public modifier: The access level of a public modifier is everywhere. It can be accessed from within the class,
outside the class, within the package and outside the package.
13. What is Java
constructor and
destructor?
13
A constructor is used to initialize a variable that means it allocates memory for the same A
constructor is nothing but automatic initialization of the object. Whenever the program
creates an object at that time constructor, is gets called automatically. You don’t need to
call this method explicitly.
On the other hand, Destructor is used to free that memory allocated during initialization.
Generally, in java, we don’t need to call the destructor explicitly. Java has a feature of
automatic garbage collection.
14. Why Constructor and
destructor is needed?
14
Constructor and destructor are mostly used to
handle memory allocation and de-allocation
efficiently.
Constructor and destructor do a very important role
in any programming language of initializing and
destroying it after use to free up the memory space.
16. What do Interface mean in
java programming?
16
An interface is a programming structure/syntax that allows the
computer to enforce certain properties on an object (class).
For example: say we have a car class and a scooter class and a truck class. Each of
these three classes should have a start_engine() action. How the "engine is started" for
each vehicle is left to each particular class, but the fact that they must have a
start_engine action is the domain of the interface.
18. What is Static Variable
if we declare any variable as static, it is known as a static variable.
18
The static variable can be used to refer to the common property of all
objects.
For example, the company name of employees, University name of
students, etc. It makes your program memory efficient
20. 6
Let's explain:
We created a class called Student with three variables –
studentName, course, and University.
The first instance – Student1 – which has access to the
variables created in its class had these values:
Student1.studentName = “AB";
Student1.course = "Data Visualization";
Student1.University = “BUBT";
Second instance –Student2 - had these values:
Student2.studentName = "CD";
Student2.course = "Data Analysis with Java";
As we declare University as a static variable that’s why we didn’t
have to create its object in the second instance.
22. 22
Explain:
Student Class has this types of values –
-studentName: String
-course: String
-University: String
The first instance – Student1 – has these values-
+studentName: String
+course: String
+University: String
Second instance – Student2- has these values-
+studentName: String
+course: String