Overview

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

Course Objectives:

• Master the Fundamentals of Object-Oriented Programming (OOP):


• Understand and articulate the four core principles of OOP: encapsulation, inheritance, polymorphism, and
abstraction.
• Explain how these principles contribute to the development of modular, reusable, and maintainable code.
• Develop Proficiency in Java Programming:
• Write, compile, and execute Java programs that demonstrate the application of OOP principles.
• Utilize Java’s syntax and semantics effectively to create well-structured and error-free code.
• Design and Implement Class Structures and Object Relationships:
• Design class hierarchies and implement relationships such as association, aggregation, and composition.
• Use inheritance to create subclasses that extend the functionality of existing classes and apply
polymorphism for flexible code design.
• Implement Abstraction and Encapsulation in Java Applications:
• Create abstract classes and interfaces to define common behavior across different classes.
• Use encapsulation to protect data and ensure that classes expose only the necessary components of their functionality.
• Utilize Java’s Standard Library and APIs:
• Employ Java’s collection framework (e.g., List, Set, Map) to manage and manipulate data effectively in an object-oriented
manner.
• Use Java’s built-in classes for file I/O, string manipulation, and other common tasks to streamline application development.
• Apply Object-Oriented Design Principles to Real-World Problems:
• Analyze real-world problems and translate them into object-oriented designs using Java.
• Develop small to medium-scale applications, such as inventory management systems, banking systems, or simple gaming
applications, applying design patterns where appropriate.
• Collaborate and Manage Code Using Modern Development Tools:
• Use version control systems like Git to manage code in collaborative projects.
• Develop proficiency in using integrated development environments (IDEs) like Eclipse, IntelliJ IDEA, or NetBeans to write,
debug, and test Java programs.
• Prepare for Advanced Topics and Industry Applications:
• Build a foundation for exploring advanced Java topics such as concurrency, networking, and enterprise Java.
• Equip students with the knowledge and skills needed for industry certifications, internships, or entry-level positions
in software development
Learning Outcomes:

• By the end of the course, students should be able to:


• Demonstrate a solid understanding of object-oriented programming concepts and their
implementation in Java.
• Design and develop Java applications that are modular, maintainable, and scalable.
• Apply design patterns and best practices to solve complex software development challenges.
• Collaborate effectively in a team environment, using modern tools and methodologies for
software development.
• These objectives will help guide students toward a comprehensive understanding of OOP
using Java, preparing them for more advanced studies or professional careers in software
development.
What is oop
(object-oriented
programming)?
• OOP stands for Object-Oriented Programming.
• Procedural programming is about writing procedures or methods that perform operations on the data, while
object-oriented programming is about creating objects that contain both data and methods.
• Object-oriented programming has several advantages over procedural programming:
• OOP is faster and easier to execute
• OOP provides a clear structure for the programs
• OOP helps to keep the Java code DRY "Don't Repeat Yourself", and makes the code easier to maintain, modify
and debug
• OOP makes it possible to create full reusable applications with less code and shorter development time
• Tip: The "Don't Repeat Yourself" (DRY) principle is about reducing the repetition of code. You should extract out
the codes that are common for the application, and place them at a single place and reuse them instead of
repeating it.
What is object-oriented
programming?
Object-oriented programming is a programming paradigm, or
classification, that organizes a group of data attributes with
functions or methods into a unit, known as an object. Typically, OOP
languages are class-based, meaning a class defines the data attributes
and functions as a blueprint for creating objects, which are instances
of the class. One class may represent multiple independent objects,
which interact with each other in complex ways. Popular class-based
programming languages include Java, Python and C++.
• For example, if a class represents a person, it may contain
attributes to represent various data, such as the person's
age, name and height. The class definition might also
contain functions, such as a function to print the person's
name on a screen. You could create a family by representing
person objects from the class of each family member. Each
person object contains different data attributes because
every person is unique.
What are the structure of object-oriented programming?
The structure, or building blocks, of object-oriented programming include
the following:
Classes are user-defined data types that act as the blueprint for
individual objects, attributes and methods.
For Example: Consider the Class of Cars. There may be many cars with different names and
brands but all of them will share some common properties like all of them will have 4
wheels, Speed Limit, Mileage range, etc. So here, Car is the class, and wheels, speed limits,
mileage are their properties.
A class is a way of organizing information about a type of data so a programmer can reuse
elements when making multiple instances of that data type—for example, if a programmer
wanted to make three instances of Car , maybe a BMW, a Ferrari, and a Ford instance.
Object: In OOP, an object represents an instance, or
creation, of a class. Objects define specific data, such
as properties and behaviors, to implement code.
• For example “Dog” is a real-life Object, which has some
characteristics like color, Breed, Bark, Sleep, and Eats.
An object is a component of a program that knows how to perform
certain actions and how to interact with other elements of the
program. Objects are the basic units of object-oriented programming.
A simple example of an object would be a person. Logically, you
would expect a person to have a name.
Method: A method is a function that performs a task or
action. For example, a method may return information about
an object's data. (behavior) a person can speak, run, walk,
and eat.
A method is like a set of instructions that tell an object what
to do. Just like how you follow a recipe to bake a cake (the
method), objects use methods to perform specific tasks.

Imagine a car (the object) - it has various methods such as


'startEngine()', 'accelerate()', and 'brake()'. Each method
helps the car perform a specific action, like starting the
engine, moving faster, or stopping.
Attribute: This structure stores information
about an object and defines its state. You can
define an attribute as part of the class.
Attributes are the characteristics of the class that help to
distinguish it from other classes. Behaviors are the tasks
that an object performs. A person's attributes, for example,
include their age, name, and height, while their behaviors
include the fact that a person can speak, run, walk, and eat.
• Let's imagine a car as an object in a program. The car object
could have attributes like:
• Colour: red
• Make: BMW
• Model: X5
• Year: 2022
• Speed: 0 (when stationary)
• Each of these attributes tells us something specific about the
car. Just like you can identify a car by its colour, make, and
model, a program can use these attributes to work with the
car object.
Basic
concepts
of oop
• 1. Data Abstraction:
• Data abstraction is one of the most essential and important features of object-
oriented programming. Data abstraction refers to providing only essential
information about the data to the outside world, hiding the background
details or implementation.
• Consider a real-life example of a man driving a car. The man only knows that
pressing the accelerators will increase the speed of the car or applying brakes
will stop the car, but he does not know about how on pressing the accelerator
the speed is increasing, he does not know about the inner mechanism of the
car or the implementation of the accelerator, brakes, etc in the car. This is what
abstraction is.
Imagine you have a car. When you drive a car, you don't really need to know how the
engine works, or how the brakes stop the wheels, or how the fuel gets into the engine.
All you need to know is how to drive it safely. That's abstraction in action.
In this example, the car itself is an abstraction. It hides all the complex details of how it
works. Instead, it gives you a simplified interface, like a steering wheel, pedals, and
buttons, which are easy to understand and use.
Now, let's relate this to programming. In OOP, we create objects (like the car in our
example) that have certain properties (like color, size, and speed) and can perform
actions (like accelerate, brake, and honk).
With abstraction, we can hide the complex inner workings of these objects from other
parts of the program. We do this by using classes and objects to represent the real-world
things we want to model in our program.
• 2. Encapsulation:
• Encapsulation is defined as the wrapping up of data under a
single unit. It is the mechanism that binds together code and
the data it manipulates. In Encapsulation, the variables or data
of a class are hidden from any other class and can be accessed
only through any member function of their class in which they
are declared. As in encapsulation, the data in a class is hidden
from other classes, so it is also known as data-hiding.
Consider a real-life example of encapsulation, in a company, there are different
sections like the accounts section, finance section, sales section, etc. The finance
section handles all the financial transactions and keeps records of all the data
related to finance. Similarly, the sales section handles all the sales-related activities
and keeps records of all the sales. Now there may arise a situation when for some
reason an official from the finance section needs all the data about sales in a
particular month. In this case, he is not allowed to directly access the data of the
sales section. He will first have to contact some other officer in the sales section and
then request him to give the particular data. This is what encapsulation is. Here the
data of the sales section and the employees that can manipulate them are wrapped
under a single name “sales section”.
• 3. Inheritance:
• Inheritance is an important pillar of OOP(Object-Oriented
Programming). The capability of a class to derive properties and
characteristics from another class is called Inheritance. When we write a
class, we inherit properties from other classes. So when we create a
class, we do not need to write all the properties and functions again and
again, as these can be inherited from another class that possesses it.
Inheritance allows the user to reuse the code whenever possible and
reduce its redundancy.

Imagine you have a family with different members, like your parents, siblings, and
grandparents. Each of these family members has some special traits that they pass on to
you. For example, you may have inherited your mom's beautiful blue eyes or your dad's
curly hair. Similarly, in programming, we can create new objects that can inherit the
qualities and behaviors from existing objects.
• 4. Polymorphism:
• Polymorphism is derived from two Greek words, “poly” and “morph”,
which means “many” and “forms” meaning having many forms. In simple
words, we can define polymorphism as the ability of a message to be
displayed in more than one form. For example, A person at the same time
can have different characteristics. Like a man at the same time is a father,
a husband, an employee. So the same person posses different behavior in
different situations. This is called polymorphism.
• Imagine you have a parent class called Animal which has a
method called makeSound(). Now, you create two child
classes: Dog and Cat. Both Dog and Cat inherit from the
Animal class and have their own version of the
makeSound() method. Here's where polymorphism comes
in – you can treat a Dog or a Cat object as an Animal
object and call the makeSound() method without
worrying about which specific type of animal it is.
ENCAPSULATION – wrapping up of data
ABSTRACTION – providing only essential
information and hiding the background details
INHERITANCE – Eliminate redundant code
POLYMORPHISM – having many forms
Why do we need object-oriented
programming
• To make the development and maintenance of projects more effortless.
• provide the feature of data hiding that is good for security concerns.
• We can solve real-world problems if we are using object-oriented programming.
• It ensures code reusability.
• It lets us write generic code: which will work with a range of data, so we don’t
have to write basic stuff over and over again.
What is Java?
Java is a popular high-level, object-oriented programming language,
which was originally developed by Sun Microsystems and released in
1995. Currently, Java is owned by Oracle and more than 3 billion
devices run Java. Java runs on a variety of platforms, such as Windows,
Mac OS, and the various versions of UNIX. Today Java is being used to
develop numerous types of software applications including Desktop
Apps, Mobile apps, Web apps, Games, and much more.
Java is a general-purpose programming language
intended to let programmers Write Once, Run
Anywhere (WORA). This means that compiled Java
code can run on all platforms that support Java
without the need to recompile.
Java is Open Source
Java is simple and so easy to learn
Java is much in demand and ensures high salary
Java has a large vibrant community
Java has powerful development tools (different IDE)
Java is platform independent
• Java programming language was originally developed
by Sun Microsystems which was initiated by James
Gosling and released in 1995 as core component of
Sun Microsystems' Java platform (Java 1.0 [J2SE]).
• The new J2 versions were renamed as Java SE, Java
EE, and Java ME respectively. Java is guaranteed to
be Write Once, Run Anywhere.
History of Java
• James Gosling initiated Java language project in June 1991 for use in one of his many set-top box
projects. The language, initially called 'Oak' after an oak tree that stood outside Gosling's office,
also went by the name 'Green' and ended up later being renamed as Java, from a list of random
words.
• Sun released the first public implementation as Java 1.0 in 1995. It promised Write Once, Run
Anywhere (WORA), providing no-cost run-times on popular platforms.
• On 13 November, 2006, Sun released much of Java as free and open source software under the
terms of the GNU General Public License (GPL).
• On 8 May, 2007, Sun finished the process, making all of Java's core code free and open-source,
aside from a small portion of code to which Sun did not hold the copyright.
Java Name History
• GreenTalk
• James Gosling was leading a team named as 'Green' team. Target of this team
was to create a new project which can. Initially C++ was the original choice to
develop the project. James Gosling wanted to enhance C++ to achieve the
target but due to high memory usage, that idea was rejected and team
started with a new language initially named as GreenTalk. The file extension
used as .gt. Later this language was termed as Oak and finally to Java.
• Oak
• James Gosling renamed language to Oak. There
was an Oak tree in front of his office. James
Gosling used this name as Oak represents
solidarity and Oak tree is the national tree of
multiple countries like USA, France, Romania
etc. But Oak technologies already had Oak as a
trademark and James team had to brainstrom
another title for the language.
• Finally Java
• Team put multiple names like DNA, Silk, Ruby and Java. Java was
finalized by the team. James Gosling tabled Java title based on
type of espresso coffee bean. Java is an island in Indonesia where
new coffee was discovered termed as Java coffee. As per James
Gosling, Java was among the top choice along with Silk. Finally Java
was selected as it was quite unique and represented the essence
of being dynamic, revolutionary and fun to say.
Java - Features
Java programming language was initially developed to work
on embedded systems, set top boxes, television. So by
requirements, it was initially designed to work on varied
platforms. Over the period of multiple years, Java evolved to
become one of the most popular language used to develop
internet based applications.

You might also like