Package and Library

Although, we have pretty much covered all basic concepts of Object-Oriented Programming (OOP). But, as I mentioned that we will discuss package and library in detail at end of our course when we were discussing ‘Abstraction‘. And also because, both package and library are basically actual implementations of some core OOP concepts that’s why I would like to discuss these before conclusion or final words for our course.

Let’s start with package first.


A package is basically a group or set of related classes.

And what are related classes? We can say that two or more classes relate with each other if they perform almost similar functionality or represent similar objects. For example, we can create a persons package in our Learning Management System that will include person class as well as all other derived classes of Person in our system in that package. Or we can create a vehicles package to group together all different type of vehicles in our car simulator or game.

Almost all programming languages come with some default packages. For example, both C++ and Java has ‘System.io’ package that consist of a set of all input and output related classes and functionality. Similarly, we also have ‘Collection’ package in Java which include all different type of collections available in Java.


A library is basically a set of one or more custom packages that solve a problem, implement an API or handle a functionality.

There are already many libraries available online that include library to implement PayPal payment processing, connect and communicate with Facebook or Google and many more.

Let’s assume you want to implement PayPal payment processing in your program or application. You have two options to achieve this. One, you will use an existing set of classes or functionality. Or you will implement everything yourself.

If you decide to use an existing set of classes or functionality to implement PayPal payment processing in your system, you are basically using a Library.

Suppose you decide and actually implement everything yourself. Now if you separate your implementation for reuse in another project or publish your implementation online somewhere on your Blog or Git repository. You are basically creating or sharing a library to implement PayPal based payment processing in any application.

We can say that both package and library are basically a practical implementation of all four major concepts of OOP that include Encapsulation, Inheritance, Abstraction and Polymorphism.

I hope this should be enough for package and library for now. But, if you still have any confusion on this, please ask your questions as comments below.

Let’s wrap up this course with some final words. Please click on ‘Next’ to continue.

Image placeholder

Hi! I'm Zeeshan Elahi

I have compiled and prepared this content with love for people like me and you. And as you know it always take some time and extra cups of coffee to read, compile and prepare a course or manual. If you have like reading this content and want to say thanks, please consider supporting from more stuff like this.

Leave a comment

Your email address will not be published. Required fields are marked *