Browse Course Material

Course info, instructors.

  • Adam Marcus

Departments

  • Electrical Engineering and Computer Science

As Taught In

  • Programming Languages
  • Software Design and Engineering

Learning Resource Types

Introduction to programming in java, lecture 4: classes and objects.

Lecture presentation on programming in Java. Topics include: object oriented programming, defining classes, using classes, constructors, methods, accessing fields, primitives versus references, references versus values, and static types and methods.

facebook

You are leaving MIT OpenCourseWare

Object-Oriented-Programming Concepts in Java

Last updated: January 25, 2024

java oop presentation

Azure Container Apps is a fully managed serverless container service that enables you to build and deploy modern, cloud-native Java applications and microservices at scale. It offers a simplified developer experience while providing the flexibility and portability of containers.

Of course, Azure Container Apps has really solid support for our ecosystem, from a number of build options, managed Java components, native metrics, dynamic logger, and quite a bit more.

To learn more about Java features on Azure Container Apps, you can get started over on the documentation page .

And, you can also ask questions and leave feedback on the Azure Container Apps GitHub page .

Whether you're just starting out or have years of experience, Spring Boot is obviously a great choice for building a web application.

Jmix builds on this highly powerful and mature Boot stack, allowing devs to build and deliver full-stack web applications without having to code the frontend. Quite flexibly as well, from simple web GUI CRUD applications to complex enterprise solutions.

Concretely, The Jmix Platform includes a framework built on top of Spring Boot, JPA, and Vaadin , and comes with Jmix Studio, an IntelliJ IDEA plugin equipped with a suite of developer productivity tools.

The platform comes with interconnected out-of-the-box add-ons for report generation, BPM, maps, instant web app generation from a DB, and quite a bit more:

>> Become an efficient full-stack developer with Jmix

Get non-trivial analysis (and trivial, too!) suggested right inside your IDE or Git platform so you can code smart, create more value, and stay confident when you push.

Get CodiumAI for free and become part of a community of over 280,000 developers who are already experiencing improved and quicker coding.

Write code that works the way you meant it to:

>> CodiumAI. Meaningful Code Tests for Busy Devs

DbSchema is a super-flexible database designer, which can take you from designing the DB with your team all the way to safely deploying the schema .

The way it does all of that is by using a design model , a database-independent image of the schema, which can be shared in a team using GIT and compared or deployed on to any database.

And, of course, it can be heavily visual, allowing you to interact with the database using diagrams, visually compose queries, explore the data, generate random data, import data or build HTML5 database reports.

>> Take a look at DBSchema

Slow MySQL query performance is all too common. Of course it is. A good way to go is, naturally, a dedicated profiler that actually understands the ins and outs of MySQL.

The Jet Profiler was built for MySQL only , so it can do things like real-time query performance, focus on most used tables or most frequent queries, quickly identify performance issues and basically help you optimize your queries.

Critically, it has very minimal impact on your server's performance, with most of the profiling work done separately - so it needs no server changes, agents or separate services.

Basically, you install the desktop application, connect to your MySQL server , hit the record button, and you'll have results within minutes:

>> Try out the Profiler

Do JSON right with Jackson

Download the E-book

Get the most out of the Apache HTTP Client

Get Started with Apache Maven:

Working on getting your persistence layer right with Spring?

Explore the eBook

Building a REST API with Spring?

Explore Spring Boot 3 and Spring 6 in-depth through building a full REST API with the framework:

>> REST With Spring (new)

Get started with Spring and Spring Boot, through the reference Learn Spring course:

>> LEARN SPRING

The AI Assistant to boost Boost your productivity writing unit tests - Machinet AI .

AI is all the rage these days, but for very good reason. The highly practical coding companion, you'll get the power of AI-assisted coding and automated unit test generation . Machinet's Unit Test AI Agent utilizes your own project context to create meaningful unit tests that intelligently aligns with the behavior of the code. And, the AI Chat crafts code and fixes errors with ease, like a helpful sidekick.

Simplify Your Coding Journey with Machinet AI :

>> Install Machinet AI in your IntelliJ

Looking for the ideal Linux distro for running modern Spring apps in the cloud?

Meet Alpaquita Linux : lightweight, secure, and powerful enough to handle heavy workloads.

This distro is specifically designed for running Java apps . It builds upon Alpine and features significant enhancements to excel in high-density container environments while meeting enterprise-grade security standards.

Specifically, the container image size is ~30% smaller than standard options, and it consumes up to 30% less RAM:

>> Try Alpaquita Containers now.

Yes, Spring Security can be complex, from the more advanced functionality within the Core to the deep OAuth support in the framework.

I built the security material as two full courses - Core and OAuth , to get practical with these more complex scenarios. We explore when and how to use each feature and code through it on the backing project .

You can explore the course here:

>> Learn Spring Security

Spring Data JPA is a great way to handle the complexity of JPA with the powerful simplicity of Spring Boot .

Get started with Spring Data JPA through the guided reference course:

>> CHECK OUT THE COURSE

Get started with Spring Boot and with core Spring, through the Learn Spring course:

1. Overview

In this article, we’ll look into Object-Oriented Programming (OOP) concepts in Java. We’ll discuss classes, objects, abstraction, encapsulation, inheritance, and polymorphism .

Classes are the starting point of all objects, and we may consider them as the template for creating objects. A class would typically contain member fields, member methods, and a special constructor method.

We’ll use the constructor to create objects of the class:

Note that a class may have more than one constructor. We can read more about the classes in our classes article.

Objects are created from classes and are called instances of the class. We create objects from classes using their constructors:

Here, we’ve created two instances of the class Car. Read more about them in our objects article.

4. Abstraction

Abstraction is hiding complexities of implementation and exposing simpler interfaces.

If we think about a typical computer, one can only see the external interface, which is most essential for interacting with it, while internal chips and circuits are hidden from the user.

In OOP, abstraction means hiding the complex implementation details of a program, exposing only the API required to use the implementation. In Java, we achieve abstraction by using interfaces and abstract classes.

We can read more about abstraction in our abstract class and interface articles.

5. Encapsulation

Encapsulation is hiding the state or internal representation of an object from the consumer of an API and providing publicly accessible methods bound to the object for read-write access. This allows for hiding specific information and controlling access to internal implementation.

For example, member fields in a class are hidden from other classes, and they can be accessed using the member methods. One way to do this is to make all data fields private and only accessible by using the public member methods:

Here, the field  speed  is encapsulated using the  private  access modifier, and can only be accessed using the  public getSpeed() and setSpeed()  methods. We can read more about access modifiers in our access modifiers article.

6. Inheritance

Inheritance is the mechanism that allows one class to acquire all the properties from another class by inheriting the class. We call the inheriting class a child class and the inherited class as the superclass or parent class.

In Java, we do this by extending the parent class. Thus, the child class gets all the properties from the parent:

When we extend a class, we form an IS-A relationship . The Car IS-A Vehicle .  So, it has all the characteristics of a Vehicle .

We may ask the question, why do we need inheritance ? To answer this, let’s consider a vehicle manufacturer who manufactures different types of vehicles, such as cars, buses, trams, and trucks.

To make the work easy, we can bundle the common features and properties of all vehicle types into a module (a class in case of Java). And we can let individual types inherit and reuse those properties:

The vehicle type Car will now inherit from the parent Vehicle class:

Java supports single inheritance and multilevel inheritance. This means a class cannot extend from more than one class directly, but it can use a hierarchy:

Here, the ArmouredCar extends Car , and Car extends Vehicle . So, ArmouredCar inherits properties from both Car and Vehicle .

While we inherit from the parent class, a developer could also override a method implementation from the parent. This is known as method overriding .

In our above example of the Vehicle class, there is the honk() method. The  Car  class extending the  Vehicle  class can override this method and implement in the way it wants to produce the honk:

Note that this is also termed a runtime polymorphism, as explained in the next section. We can read more about inheritance in our Java inheritance and inheritance and composition articles.

7. Polymorphism

Polymorphism is the ability of an OOP language to process data differently depending on their types of inputs. In Java, this can be the same method name having different method signatures and performing different functions:

In this example, we can see that the method read()  has three different forms with different functionalities. This type of polymorphism is static or compile-time polymorphism and is also called method overloading .

There is also runtime or dynamic polymorphism, where the child class overrides the parent’s method :

A child class can extend the  GenericFile  class and override the  getFileInfo()  method:

Read more about polymorphism in our polymorphism in Java article.

8. Conclusion

In this article, we learned about the basic fundamental concepts of OOP with Java.

The code samples in this article are available over on Github .

Slow MySQL query performance is all too common. Of course it is.

The Jet Profiler was built entirely for MySQL , so it's fine-tuned for it and does advanced everything with relaly minimal impact and no server changes.

Just published a new writeup on how to run a standard Java/Boot application as a Docker container, using the Liberica JDK on top of Alpaquita Linux:

>> Spring Boot Application on Liberica Runtime Container.

Explore the secure, reliable, and high-performance Test Execution Cloud built for scale. Right in your IDE:

Basically, write code that works the way you meant it to.

AI is all the rage these days, but for very good reason. The highly practical coding companion, you'll get the power of AI-assisted coding and automated unit test generation . Machinet's Unit Test AI Agent utilizes your own project context to create meaningful unit tests that intelligently aligns with the behavior of the code.

Build your API with SPRING - book cover

The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available. See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases. See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.

Lesson: Object-Oriented Programming Concepts

If you've never used an object-oriented programming language before, you'll need to learn a few basic concepts before you can begin writing any code. This lesson will introduce you to objects, classes, inheritance, interfaces, and packages. Each discussion focuses on how these concepts relate to the real world, while simultaneously providing an introduction to the syntax of the Java programming language.

What Is an Object?

An object is a software bundle of related state and behavior. Software objects are often used to model the real-world objects that you find in everyday life. This lesson explains how state and behavior are represented within an object, introduces the concept of data encapsulation, and explains the benefits of designing your software in this manner.

What Is a Class?

A class is a blueprint or prototype from which objects are created. This section defines a class that models the state and behavior of a real-world object. It intentionally focuses on the basics, showing how even a simple class can cleanly model state and behavior.

What Is Inheritance?

Inheritance provides a powerful and natural mechanism for organizing and structuring your software. This section explains how classes inherit state and behavior from their superclasses, and explains how to derive one class from another using the simple syntax provided by the Java programming language.

What Is an Interface?

An interface is a contract between a class and the outside world. When a class implements an interface, it promises to provide the behavior published by that interface. This section defines a simple interface and explains the necessary changes for any class that implements it.

What Is a Package?

A package is a namespace for organizing classes and interfaces in a logical manner. Placing your code into packages makes large software projects easier to manage. This section explains why this is useful, and introduces you to the Application Programming Interface (API) provided by the Java platform.

Questions and Exercises: Object-Oriented Programming Concepts

Use the questions and exercises presented in this section to test your understanding of objects, classes, inheritance, interfaces, and packages.

About Oracle | Contact Us | Legal Notices | Terms of Use | Your Privacy Rights

Copyright © 1995, 2022 Oracle and/or its affiliates. All rights reserved.

Java Tutorial

Java methods, java classes, java file handling, java how to's, java reference, java examples, java - what is oop.

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.

Java - What are Classes and Objects?

Classes and objects are the two main aspects of object-oriented programming.

Look at the following illustration to see the difference between class and objects:

Another example:

So, a class is a template for objects, and an object is an instance of a class.

When the individual objects are created, they inherit all the variables and methods from the class.

You will learn much more about classes and objects in the next chapter.

Get Certified

COLOR PICKER

colorpicker

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: [email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail: [email protected]

Top Tutorials

Top references, top examples, get certified.

Javatpoint Logo

Java Object Class

Java inheritance, java polymorphism, java abstraction, java encapsulation, java oops misc.

JavaTpoint

In this page, we will learn about the basics of OOPs. Object-Oriented Programming is a paradigm that provides many concepts, such as , , , etc.

is considered the first object-oriented programming language. The programming paradigm where everything is represented as an object is known as a truly object-oriented programming language.

is considered the first truly object-oriented programming language.

The popular object-oriented languages are , , , , , etc.

The main aim of object-oriented programming is to implement real-world entities, for example, object, classes, abstraction, inheritance, polymorphism, etc.

means a real-world entity such as a pen, chair, table, computer, watch, etc. is a methodology or paradigm to design a program using classes and objects. It simplifies software development and maintenance by providing some concepts:

Apart from these concepts, there are some other terms which are used in Object-Oriented design:

An Object can be defined as an instance of a class. An object contains an address and takes up some space in memory. Objects can communicate without knowing the details of each other's data or code. The only necessary thing is the type of message accepted and the type of response returned by the objects.

A dog is an object because it has states like color, name, breed, etc. as well as behaviors like wagging the tail, barking, eating, etc.

is called class. It is a logical entity.

A class can also be defined as a blueprint from which you can create an individual object. Class doesn't consume any space.

, it is known as inheritance. It provides code reusability. It is used to achieve runtime polymorphism.

If , it is known as polymorphism. For example: to convince the customer differently, to draw something, for example, shape, triangle, rectangle, etc.

In Java, we use method overloading and method overriding to achieve polymorphism.

Another example can be to speak something; for example, a cat speaks meow, dog barks woof, etc.

is known as abstraction. For example phone call, we don't know the internal processing.

In Java, we use abstract class and interface to achieve abstraction.

. For example, a capsule, it is wrapped with different medicines.

A java class is the example of encapsulation. Java bean is the fully encapsulated class because all the data members are private here.

Coupling refers to the knowledge or information or dependency of another class. It arises when classes are aware of each other. If a class has the details information of another class, there is strong coupling. In Java, we use private, protected, and public modifiers to display the visibility level of a class, method, and field. You can use interfaces for the weaker coupling because there is no concrete implementation.

Cohesion refers to the level of a component which performs a single well-defined task. A single well-defined task is done by a highly cohesive method. The weakly cohesive method will split the task into separate parts. The java.io package is a highly cohesive package because it has I/O related classes and interface. However, the java.util package is a weakly cohesive package because it has unrelated classes and interfaces.

Association represents the relationship between the objects. Here, one object can be associated with one object or many objects. There can be four types of association between the objects:

Let's understand the relationship with real-time examples. For example, One country can have one prime minister (one to one), and a prime minister can have many ministers (one to many). Also, many MP's can have one prime minister (many to one), and many ministers can have many departments (many to many).

Association can be undirectional or bidirectional.

Aggregation is a way to achieve Association. Aggregation represents the relationship where one object contains other objects as a part of its state. It represents the weak relationship between objects. It is also termed as a relationship in Java. Like, inheritance represents the relationship. It is another way to reuse objects.

The composition is also a way to achieve Association. The composition represents the relationship where one object contains other objects as a part of its state. There is a strong relationship between the containing object and the dependent object. It is the state where containing objects do not have an independent existence. If you delete the parent object, all the child objects will be deleted automatically.

1) OOPs makes development and maintenance easier, whereas, in a procedure-oriented programming language, it is not easy to manage if code grows as project size increases.

2) OOPs provides data hiding, whereas, in a procedure-oriented programming language, global data can be accessed from anywhere.


3) OOPs provides the ability to simulate real-world event much more effectively. We can provide the solution of real word problem if we are using the Object-Oriented Programming language.

Object-based programming language follows all the features of OOPs except Inheritance. JavaScript and VBScript are examples of object-based programming languages.







Youtube

  • Send your Feedback to [email protected]

Help Others, Please Share

facebook

Learn Latest Tutorials

Splunk tutorial

Transact-SQL

Tumblr tutorial

Reinforcement Learning

R Programming tutorial

R Programming

RxJS tutorial

React Native

Python Design Patterns

Python Design Patterns

Python Pillow tutorial

Python Pillow

Python Turtle tutorial

Python Turtle

Keras tutorial

Preparation

Aptitude

Verbal Ability

Interview Questions

Interview Questions

Company Interview Questions

Company Questions

Trending Technologies

Artificial Intelligence

Artificial Intelligence

AWS Tutorial

Cloud Computing

Hadoop tutorial

Data Science

Angular 7 Tutorial

Machine Learning

DevOps Tutorial

B.Tech / MCA

DBMS tutorial

Data Structures

DAA tutorial

Operating System

Computer Network tutorial

Computer Network

Compiler Design tutorial

Compiler Design

Computer Organization and Architecture

Computer Organization

Discrete Mathematics Tutorial

Discrete Mathematics

Ethical Hacking

Ethical Hacking

Computer Graphics Tutorial

Computer Graphics

Software Engineering

Software Engineering

html tutorial

Web Technology

Cyber Security tutorial

Cyber Security

Automata Tutorial

C Programming

C++ tutorial

Control System

Data Mining Tutorial

Data Mining

Data Warehouse Tutorial

Data Warehouse

RSS Feed

Object-Oriented Programming Principles  in Java:  OOP Concepts for Beginners

Thanoshan MV

Object-oriented programming offers a sustainable way to write spaghetti code. It lets you accrete programs as a series of patches. ― Paul Graham

Fundamentals of object-oriented programming

Object-oriented programming is a programming paradigm where everything is represented as an object.

Objects pass messages to each other. Each object decides what to do with a received message. OOP focuses on each object’s states and behaviors.

What Are Objects?

An object is an entity that has states and behaviors.

For example, dog, cat, and vehicle. To illustrate, a dog has states like age, color, name, and behaviors like eating, sleeping, and running.

State tells us how the object looks or what properties it has.

Behavior tells us what the object does.

We can actually represent a real world dog in a program as a software object by defining its states and behaviors.

Software objects are the actual representation of real world objects. Memory is allocated in RAM whenever creating a logical object.

An object is also referred to an instance of a class. Instantiating a class means the same thing as creating an object.

The important thing to remember when creating an object is: the reference type should be the same type or a super type of the object type. We’ll see what a reference type is later in this article.

What Are Classes?

A class is a template or blueprint from which objects are created.

Imagine a class as a cookie-cutter and objects as cookies.

cookie-cutter

Classes define states as instance variables and behaviors as instance methods.

Instance variables are also known as member variables.

Classes don't consume any space.

To give you an idea about classes and objects, let's create a Cat class that represents states and behaviors of real world Cat.

Now we have successfully defined a template for Cat. Let’s say we have two cats named Thor and Rambo.

Russian-Blue_01

How can we define them in our program?

First, we need to create two objects of the Cat class.

Next, we’ll define their states and behaviors.

Like the above code examples, we can define our class, instantiate it (create objects) and specify the states and behaviors for those objects.

Now, we have covered the basics of object-oriented programming. Let's move on to the principles of object-oriented programming.

Principles of object-oriented programming

These are the four main principles of the object-oriented programming paradigm. Understanding them is essential to becoming a successful programmer.

Encapsulation

Inheritance, abstraction, polymorphism.

Now let's look at each in more detail.

Encapsulation is a process of wrapping code and data together into a single unit.

It's just like a capsule that contains a mix of several medicines, and is a technique that helps keep instance variables protected.

This can be achieved by using private access modifiers that can’t be accessed by anything outside the class. In order to access private states safely, we have to provide public getter and setter methods. (In Java, these methods should follow JavaBeans naming standards.)

Let’s say there is a record shop that sells music albums of different artists and a stock keeper who manages them.

classDiagramWithoutEncapsulation

If you look at figure 4, the StockKeeper class can access the Album class’s states directly as Album class’s states are set to public .

What if the stock keeper creates an album and sets states to negative values? This can be done intentionally or unintentionally by a stock keeper.

To illustrate, let’s see a sample Java program that explains the above diagram and statement.

Album class:

StockKeeper class:

Main class:

The album’s price and number of copies can’t be negative values. How can we avoid this situation? This is where we use encapsulation.

classDiagramWithEncapsulation-1

In this scenario, we can block the stock keeper from assigning negative values. If they attempt to assign negative values for the album’s price and number of copies, we’ll assign them as 0.0 and 0.

With encapsulation, we’ve blocked our stock keeper from assigning negative values, meaning we have control over the data.

Advantages of encapsulation in Java

  • We can make a class read-only or write-only : for a read-only class, we should provide only a getter method. For a write-only class, we should provide only a setter method.
  • Control over the data: we can control the data by providing logic to setter methods, just like we restricted the stock keeper from assigning negative values in the above example.
  • Data hiding: other classes can’t access private members of a class directly.

Let’s say that the record shop we discussed above also sells Blu-ray movies.

classDiagramForMovie

As you can see in the above diagram, there are many common states and behaviors (common code) between Album and Movie .

When implementing this class diagram into code, are you going to write (or copy & paste) the entire code for Movie ? If you do, you are repeating yourself. How can you avoid code duplication?

This is where we use inheritance.

Inheritance is a mechanism in which one object acquires all the states and behaviors of a parent object.

Inheritance uses a parent-child relationship (IS-A relationship).

So what exactly is inherited?

Visibility/access modifiers impact what gets inherited from one class to another.

In Java, as a rule of thumb we make instance variables private and instance methods public .

In this case, we can safely say that the following are inherited:

  • public instance methods.
  • private instance variables (private instance variables can be accessed only through public getter and setter methods).

Types of Inheritance in Java

There are five types of inheritance in Java. They are single, multilevel, hierarchical, multiple, and hybrid.

Class allows single, multilevel and hierarchical inheritances. Interface allows multiple and hybrid inheritances.

InheritanceTypes

A class can extend only one class however it can implement any number of interfaces. An interface can extend more than one interfaces.

inheritanceKeywords

Relationships

I. IS-A relationship

An IS-A relationship refers to inheritance or implementation.

a. Generalization

Generalization uses an IS-A relationship from a specialization class to generalization class.

generalization

II. HAS-A relationship

An instance of one class HAS-A reference to an instance of another class.

a. Aggregation

In this relationship, the existence of class A and B are not dependent on each other.

For this aggregation part, we going to see an example of the Student class and the ContactInfo class.

aggregation-1

Student HAS-A ContactInfo . ContactInfo can be used in other places – for example, a company's Employee class can also use this ContactInfo class. So Student can exist without ContactInfo and ContactInfo can exist without Student . This type of relationship is known as aggregation.

b. Composition

In this relationship, class B can not exist without class A – but class A can exist without class B.

To give you an idea about composition, let's see an example of the Student class and the StudentId class.

composition--1-

Student HAS-A StudentId . Student can exist without StudentId but StudentId can not exist without Student . This type of relationship is known as composition.

Now, let’s back to our previous record shop example that we discussed above.

classDiagramWithInheritance

We can implement this diagram in Java to avoid code duplication.

Advantages of inheritance

  • Code reuse: the child class inherits all instance members of the parent class.
  • You have more flexibility to change code: changing code in place is enough.
  • You can use polymorphism: method overriding requires IS-A relationship.

Abstraction is a process of hiding the implementation details and showing only functionality to the user.

A common example of abstraction is that pressing the accelerator will increase the speed of a car. But the driver doesn’t know how pressing the accelerator increases the speed – they don't have to know that.

Technically abstract means something incomplete or to be completed later.

In Java, we can achieve abstraction in two ways: abstract class (0 to 100%) and interface (100%).

The keyword abstract can be applied to classes and methods. abstract and final or static can never be together.

I. Abstract class

An abstract class is one that contains the keyword abstract .

Abstract classes can’t be instantiated (can’t create objects of abstract classes). They can have constructors, static methods, and final methods.

II. Abstract methods

An abstract method is one that contains the keyword abstract .

An abstract method doesn’t have implementation (no method body and ends up with a semi colon). It shouldn’t be marked as private .

III. Abstract class and Abstract methods

  • If at least one abstract method exists inside a class then the whole class should be abstract.
  • We can have an abstract class with no abstract methods.
  • We can have any number of abstract as well as non-abstract methods inside an abstract class at the same time.
  • The first concrete sub class of an abstract class must provide implementation to all abstract methods.
  • If this doesn't happen, then the sub class also should be marked as abstract.

In a real world scenario, the implementation will be provided by someone who is unknown to end users. Users don’t know the implementation class and the actual implementation.

Let’s consider an example of abstract concept usage.

abstraction

When do we want to mark a class as abstract?

  • To force sub classes to implement abstract methods.
  • To stop having actual objects of that class.
  • To keep having a class reference.
  • To retain common class code.

An interface is a blueprint of a class.

An interface is 100% abstract. No constructors are allowed here. It represents an IS-A relationship.

NOTE: Interfaces only define required methods. We can not retain common code.

An interface can have only abstract methods, not concrete methods. By default, interface methods are public and abstract . So inside the interface, we don’t need to specify public and abstract .

So when a class implements an interface’s method without specifying the access level of that method, the compiler will throw an error stating “Cannot reduce the visibility of the inherited method from interface” . So that implemented method’s access level must be set to public .

By default, interface variables are public , static and final .

For instance:

Let’s see an example that explains the interface concept:

interface

Default and Static methods in Interfaces

Usually we implement interface methods in a separate class. Let’s say we are required to add a new method in an interface. Then we must implement that method in that separate class, too.

To overcome this issue Java 8 introduced default and static methods that implement methods inside an interface, unlike abstract methods.

  • Default method
  • Static method

Similar to static methods of classes, we can call them by their interface’s name.

  • Marker interface

It’s an empty interface. For instance, Serializable, Cloneable, and Remote interfaces.

Advantages of interfaces

  • They help us use multiple inheritance in Java.
  • They provide abstraction.
  • They provide loose coupling: objects are independent from one another.

When do we want to change a class to an interface?

NOTE: Remember, we can’t retain common code inside the interface.

If you want to define potentially required methods and common code, use an abstract class .

If you just want to define a required method, use an interface .

Polymorphism is the ability of an object to take on many forms.

Polymorphism in OOP occurs when a super class references a sub class object.

All Java objects are considered to be polymorphic as they share more than one IS-A relationship (at least all objects will pass the IS-A test for their own type and for the class Object).

We can access an object through a reference variable. A reference variable can be of only one type. Once declared, the type of a reference variable cannot be changed.

A reference variable can be declared as a class or interface type.

A single object can be referred to by reference variables of many different types as long as they are the same type or a super type of the object.

Method overloading

If a class has multiple methods that have same name but different parameters, this is known as method overloading.

Method overloading rules:

  • Must have a different parameter list.
  • May have different return types.
  • May have different access modifiers.
  • May throw different exceptions.

NOTE: Static methods can also be overloaded.

NOTE: We can overload the main() method but the Java Virtual Machine (JVM) calls the main() method that receives String arrays as arguments.

Rules to follow for polymorphism

Compile time rules.

  • Compiler only knows reference type.
  • It can only look in reference type for methods.
  • Outputs a method signature.

Run time rules

  • At runtime, JVM follows exact runtime type (object type) to find method.
  • Must match compile time method signature to method in actual object’s class.

Method overriding

If a subclass has the same method as declared in the super class, this is known as method overriding.

Method overriding rules:

  • Must have the same parameter list.
  • Must have the same return type: although a covariant return allows us to change the return type of the overridden method.
  • Must not have a more restrictive access modifier: may have a less restrictive access modifier.
  • Must not throw new or broader checked exceptions: may throw narrower checked exceptions and may throw any unchecked exception.
  • Only inherited methods may be overridden (must have IS-A relationship).

Example for method overriding:

NOTE: Static methods can’t be overridden because methods are overridden at run time. Static methods are associated with classes while instance methods are associated with objects. So in Java, the main() method also can’t be overridden.

NOTE: Constructors can be overloaded but not overridden.

Object types and reference types

In Person mary = new Student(); , this object creation is perfectly fine.

mary is a Person type reference variable and new Student() will create a new Student object.

mary can’t access study() in compile time because the compiler only knows the reference type. Since there is no study() in the reference type class, it can’t access it. But in runtime mary is going to be the Student type (Runtime type/ object type).

Please review this post for more information on runtime types.

In this case, we can convince the compiler by saying “at runtime, mary will be Student type, so please allow me to call it”. How can we convince the compiler like this? This is where we use casting.

We can make mary a Student type in compile time and can call study() by casting it.

We’ll learn about casting next.

Object type casting

Java type casting is classified into two types:

  • Widening casting (implicit): automatic type conversion.
  • Narrowing casting (explicit): need explicit conversion.

In primitives, long is a larger type than int . Like in objects, the parent class is a larger type than the child class.

The reference variable only refers to an object. Casting a reference variable doesn’t change the object on the heap but it labels the same object in another way by means of instance members accessibility.

I. Widening casting

II. Narrowing casting

We have to be careful when narrowing. When narrowing, we convince the compiler to compile without any error. If we convince it wrongly, we will get a run time error (usually ClassCastException ).

In order to perform narrowing correctly, we use the instanceof operator. It checks for an IS-A relationship.

As I already stated before, we must remember one important thing when creating an object using the new keyword: the reference type should be the same type or a super type of the object type.

Thank you everyone for reading. I hope this article helped you.

I strongly encourage you to read more related articles on OOP.

Checkout my original article series on Medium: Object-oriented programming principles in Java

Please feel free to let me know if you have any questions.

Dream is not that which you see while sleeping it is something that does not let you sleep. ― A P J Abdul Kalam, Wings of Fire: An Autobiography

Happy Coding!

System.out.println("Hey there, I am Thanoshan!");

If this article was helpful, share it .

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

SlidePlayer

  • My presentations

Auth with social network:

Download presentation

We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!

Presentation is loading. Please wait.

Introduction to Object Oriented Programming Java.

Published by Frederica Mosley Modified over 9 years ago

Similar presentations

Presentation on theme: "Introduction to Object Oriented Programming Java."— Presentation transcript:

Introduction to Object Oriented Programming Java

Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.

java oop presentation

General OO Concepts Objectives For Today: Discuss the benefits of OO Programming Inheritance and Aggregation Abstract Classes Encapsulation Introduce Visual.

java oop presentation

Polymorphism. 3 Fundamental Properties of OO 1. Encapsulation 2. Polymorphism 3. Inheritance These are the 3 building blocks of object-oriented design.

java oop presentation

Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.

java oop presentation

©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.

java oop presentation

Object Oriented Programming in Java. Object Oriented Programming Concepts in Java Object oriented Programming is a paradigm or organizing principle for.

java oop presentation

IMS1805 Systems Analysis Topic 3: Doing Analysis (continued from previous weeks)

java oop presentation

Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:

java oop presentation

OBJECT-ORIENTED PROGRAMMING. What is an “object”? Abstract entity that contains data and actions Attributes (characteristics) and methods (functions)

java oop presentation

7M701 1 Software Engineering Object-oriented Design Sommerville, Ian (2001) Software Engineering, 6 th edition: Chapter 12 )

java oop presentation

1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)

java oop presentation

Objects First with Java A Practical Introduction using BlueJ

java oop presentation

Basic OOP Concepts and Terms

java oop presentation

Object-oriented Programming Concepts

java oop presentation

WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.

java oop presentation

CO320 Introduction to Object- Oriented Programming Michael Kölling 3.0.

java oop presentation

5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.

java oop presentation

OBJECT ORIENTED PROGRAMMING IN C++ LECTURE

java oop presentation

BACS 287 Basics of Object-Oriented Programming 1.

java oop presentation

Object Oriented Programming

About project

© 2024 SlidePlayer.com Inc. All rights reserved.

Introduction to �Object Oriented Programming�

Gayathri Namasivayam

Introduction to OOP

  • Why use OOP?
  • Building blocks of OOP
  • What is OOP?
  • OOP concepts
  • Abstraction
  • Encapsulation
  • Inheritance
  • Polymorphism
  • Advantages vs Disadvantages
  • Object Oriented Programming (OOP) is one of the most widely used programming paradigm
  • Why is it extensively used?
  • Well suited for building trivial and complex applications
  • Allows re-use of code thereby increasing productivity
  • New features can be easily built into the existing code
  • Reduced production cost and maintenance cost
  • Common programming languages used for OOP include C++, Java, and C#

Building Blocks of OOP: Objects & Classes

  • Object: models a
  • Real world object (ex. computer, book, box)
  • Concept (ex. meeting, interview)
  • Process (ex. sorting a stack of papers or comparing two computers to measure their performance)
  • Class: prototype or blueprint from which objects are created
  • Set of attributes or properties that describes every object
  • Set of behavior or actions that every object can perform
  • Set of data (value for each of its attribute)
  • Set of actions that it can perform
  • An identity
  • Every object belongs to a class

Real World Example of Objects & Classes

Object: FordCar1

Start, Accelerate, Reverse, Stop

Color: Yellow

Type: Coupe

Model: Mustang

Cylinder: 6

Color, Type, Model, Cylinder

Class: FordCar

Color: Orange

Model: Focus

Cylinder: 4

Object: FordCar2

Another Real World Example..

Name, Height, Age

Speak, Listen, Eat, Run, Walk

Class: Person

Object: Person1

Height: 5’ 4”

Height: 5’ 9”

Object: Person2

  • A class is a set of variables (to represent its attributes) and functions (to describe its behavior) that act on its variables

Class ShippingBox

int shipping_cost() {

return cost_per_pound*weight;

sender_name : string

receiver_name : string

cost_per_pound : int

weight : int

shipping_cost() : int

  • Object is an instance of a class that holds data (values) in its variables. Data can be accessed by its functions

Objects of ShippingBox class

sender_name = Jim

receiver_name = John

cost_per_pound = 5

weight = 10

shipping_cost()

Object BoxB

Object BoxA

sender_name = Julie

receiver_name = Jill

cost_per_pound = 2

  • Paradigm for problem solving by interaction among objects
  • It follows a natural way of solving problems
  • Ex. Ann wants to start her car

(1) Ann walks to her car

(2) Ann sends a message to the car to start by turning on the ignition

(3)The car starts

Problem Solving in OOP

Problem: Ann wants to start her car

Color = Yellow

Type = Coupe

Model = Mustang

Cylinder = 6

Accelerate()

Object Ann’s car

  • Extracting essential properties and behavior of an entity
  • Class represents such an abstraction and is commonly referred to as an abstract data type

Ex. In an application that computes the shipping cost of a box, we extract its properties: cost_per_pound, weight and its behavior: shipping_cost()

Shipping Box

Sender’s name,

Receiver’s name,

Cost of shipping per pound,

Calculate shipping cost

sender_name

receiver_name

cost_per_pound

shipping_cost ()

  • Mechanism by which we combine data and the functions that manipulate the data into one unit
  • Objects & Classes enforce encapsulation
  • Create new classes (derived classes) from existing classes (base classes)
  • The derived class inherits the variables and functions of the base class and adds additional ones!
  • Provides the ability to re-use existing code

Inheritance Example

BankAccount CheckingAccount SavingsAccount

customer_name : string

account_type : string

balance : int

insufficient_funds_fee : int

deposit() : int

withdrawal() : int

process_deposit() : int

interest_rate : int

calculate_interest() : int

CheckingAccount

SavingsAccount

BankAccount

  • Polymorphism*

(* To be covered in the next class)

Disadvantages of OOP

  • Initial extra effort needed in accurately modeling the classes and sub-classes for a problem
  • Suited for modeling certain real world problems as opposed to some others
  • Classes & Objects
  • Concepts in OOP
  • Advantages & Disadvantages
  • Be prepared for an in-class activity (based on topics covered today)!
  • Polymorphism in OOP!

PowerShow.com - The best place to view and share online presentations

  • Preferences

Free template

OOPS Concept in JAVA - PowerPoint PPT Presentation

java oop presentation

OOPS Concept in JAVA

This ppt including oops concepts in java – powerpoint ppt presentation.

  • In this page, we will learn about basics of OOPs. Object Oriented Programming is a paradigm that provides many concepts such as inheritance, data binding, polymorphism etc.
  • Object means a real word entity such as pen, chair, table etc. Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies the software development and maintenance by providing some concepts
  • Inheritance
  • Polymorphism
  • Abstraction
  • Encapsulation
  • Any entity that has state and behavior is known as an object. For example chair, pen, table, keyboard, bike etc. It can be physical and logical.
  • Collection of objects is called class. It is a logical entity.
  • When one object acquires all the properties and behaviours of parent object i.e. known as inheritance. It provides code reusability. It is used to achieve runtime polymorphism.
  • When one task is performed by different ways i.e. known as polymorphism. For example to convince the customer differently, to draw something e.g. shape or rectangle etc.
  • In java, we use method overloading and method overriding to achieve polymorphism.
  • Another example can be to speak something e.g. cat speaks meaw, dog barks woof etc.
  • Hiding internal details and showing functionality is known as abstraction. For example phone call, we don't know the internal processing.
  • In java, we use abstract class and interface to achieve abstraction.
  • Binding (or wrapping) code and data together into a single unit is known as encapsulation. For example capsule, it is wrapped with different medicines.
  • A java class is the example of encapsulation. Java bean is the fully encapsulated class because all the data members are private here.
  • OOPs makes development and maintenance easier where as in Procedure-oriented programming language it is not easy to manage If code grows as project size grows.
  • OOPs provides data hiding whereas in Procedure-oriented programming language a global data can be accessed from anywhere.
  • OOPs provides ability to simulate real-world event much more effectively. We can provide the solution of real word problem if we are using the Object-Oriented Programming language.

PowerShow.com is a leading presentation sharing website. It has millions of presentations already uploaded and available with 1,000s more being uploaded by its users every day. Whatever your area of interest, here you’ll be able to find and view presentations you’ll love and possibly download. And, best of all, it is completely free and easy to use.

You might even have a presentation you’d like to share with others. If so, just upload it to PowerShow.com. We’ll convert it to an HTML5 slideshow that includes all the media types you’ve already added: audio, video, music, pictures, animations and transition effects. Then you can share it with your target audience as well as PowerShow.com’s millions of monthly visitors. And, again, it’s all free.

About the Developers

PowerShow.com is brought to you by  CrystalGraphics , the award-winning developer and market-leading publisher of rich-media enhancement products for presentations. Our product offerings include millions of PowerPoint templates, diagrams, animated 3D characters and more.

World's Best PowerPoint Templates PowerPoint PPT Presentation

slide1

Java OOPs Tutorial For Beginners | Java Object Oriented Programming | Java OOPs Basics | Simplilearn

Feb 28, 2020

220 likes | 266 Views

This presentation on Java OOPs will give an introduction to Java Object-Oriented Programming. This video explains how to create and use OOP concepts. Whether you are an experienced programmer or not, this channel is intended for everyone who wishes to learn Java programming. You will also learn about all the OOP concepts: Abstraction, Encapsulation, Polymorphism, and Inheritance. And, at the end of all concepts, you will see an interesting program so that you will have in-depth knowledge of of oops concepts in Java. <br><br>Below topics are explained in this Java programming presentation: <br>1. Java OOP concepts<br>2. Abstraction<br>3. Encapsulation<br>4. Polymorphism<br>5. Inheritance<br><br>About Simplilearn Java certification training course:<br>If youu2019re looking to master web application development for virtually any computing platform, this Java Certification Training course is for you. This all-in-one Java training will give you a firm foundation in Java, the most commonly used programming language in software development.<br><br>This advanced Java Certification Training course is designed to guide you through the concepts of Java from introductory techniques to advanced programming skills. The course will provide you with the knowledge of Core Java 8, operators, arrays, loops, methods, and constructors while giving you hands-on experience in JDBC and JUnit framework.<br><br>Java Certification Course Key Features:<br>1. 70 hours of blended training<br>2. Hands-on coding and implementation of two web-based projects<br>3. Includes Hibernate and Spring frameworks<br>4. 35 coding-related exercises on Core Java 8<br>5. Lifetime access to self-paced learning<br>6. Flexibility to choose classes<br><br>Eligibility:<br>Simplilearnu2019s Java Certification Training course is ideal for software developers, web designers, programming enthusiasts, engineering graduates, and students or professionals who wish to become Java developers.<br><br>Pre-requisites:<br>Prior knowledge of Core Java is a prerequisite to taking this advanced Java Certification training course. Our Core Java online self-paced course is available for free to become familiar with the basics of Java programming.<br><br>Learn more at https://www.simplilearn.com/mobile-and-software-development/java-javaee-soa-development-training

Share Presentation

Simplilearn

Presentation Transcript

What’s in it for you? Java OOPs concepts 1 Abstraction 2 Encapsulation 3 Polymorphism 4 Inheritance 5

Java OOPs concepts

Click here to watch the video

Java OOP Object Oriented Programming (OOP) is a method to design a program using classes and objects that relate to the real world Java OOP Inheritance Polymorphism Abstraction Encapsulation

Abstraction

Abstraction Abstraction means showing the relevant details and hiding all the backend or internal details

Abstraction Abstraction means showing the relevant details and hiding all the backend or internal details abstract class class_name{ } Syntax for abstract class

Abstraction Abstraction means showing the relevant details and hiding all the backend or internal details } Relevant details } Irrelevant details

Encapsulation

Encapsulation Encapsulation is like a capsule. The whole code and data is bounded together into a single unit

Encapsulation Encapsulation is like a capsule. The whole code and data is bounded together into a single unit Variables and methods are defined inside one class like a capsule

Polymorphism

Polymorphism Polymorphism means one task is performed in different ways. One function is used for different tasks. There are two methods of polymorphism

Polymorphism Polymorphism means one task is is performed in different ways. One function is used for different tasks. There are two methods of polymorphism

Polymorphism Polymorphism means one task is is performed in different ways. One function is used for different tasks multiply() Method overloading multiply() int a, int b; multiply() int a,b,c; multiply() Double a,b;

Polymorphism Polymorphism means one task is is performed in different ways. One function is used for different tasks Cars topSpeed() Method overriding BMW 150 kmps Mercedes 180 kmps Audi 200 kmps

Inheritance

Inheritance When one class inherits some properties and attributes of other class, it is known as inheritance

  • More by User

Object Oriented Java Programming

Object Oriented Java Programming

2. ????????????. ????????????????? Constructor???????????????????????????????????????????????????????????????????????????????. 3. Constructor. constructor ?????????????????????????????????? ??????????????????[modifier] ClassName([arguments]) {[statements]}???????????????????????????????

477 views • 31 slides

Java Object-Oriented Programming

Java Object-Oriented Programming

Java Object-Oriented Programming. Outline 1 Introduction 2 Superclasses and Subclasses 3 protected Members 4 Relationship between Superclass Objects and Subclass Objects 5 Implicit Subclass-Object-to-Superclass-Object Conversion 6 Software Engineering with Inheritance

776 views • 62 slides

Object-Oriented Programming in Java

Object-Oriented Programming in Java

Object-Oriented Programming in Java. Object-Oriented Programming. Objects are the basic building blocks in an O-O program. A program consists of one or more classes that define object type. The First Program. p ublic class Driver { public static void main(String[] args ) {

524 views • 14 slides

OBJECT-ORIENTED PROGRAMMING WITH JAVA

OBJECT-ORIENTED PROGRAMMING WITH JAVA

OBJECT-ORIENTED PROGRAMMING WITH JAVA. Introduction to Java Programming The applications in Java : Applications and Applets Object-Based Programming Object-Oriented Programming: Inheritance Object-Oriented Programming: Polymorphism Data Structures, Collections Networking

293 views • 2 slides

Object-Oriented Programming (Java)

Object-Oriented Programming (Java)

Object-Oriented Programming (Java). Topics Covered Today. Unit 1.1 Java Applications 1.1.5 Exception Objects 1.1.6 Code Convention 1.1.7 Javadoc. Program Errors. Syntax (compiler) errors Errors in code construction (grammar, types) Detected during compilation Run-time errors

586 views • 46 slides

Object-Oriented Programming (Java)

Object-Oriented Programming (Java). Topics Covered Today. Unit 1.1 Java Applications 1.1.8 Debugging 1.1.9 Debugging with Eclipse. Types of Errors. There are three general types of errors: Syntax (or “compile time”) errors

601 views • 44 slides

Java Object Oriented Programming

Java Object Oriented Programming

Java Object Oriented Programming. What is it?. What is the Java API. API stands for Application Programming Interface The API is a large collection of ready-made software components that provide many useful capabilities.

471 views • 35 slides

Java and oops

Java and oops

Java is a general-purpose computer programming language that is concurrent, class-based, object-oriented,and specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA)

390 views • 18 slides

Learn Java - Java Tutorial for Beginners - Java Tutorial

Learn Java - Java Tutorial for Beginners - Java Tutorial

Learn JAVA tutorial - This Java tutorial is specially prepared for the Beginners who wants to learn Java programming language from the basics. This tutorial is prepared by Easy Web Solutions located in Panchkula that provides 6 months industrial training in Java, Android, IOS, PHP, ASP.NET, and Digital Marketing.

1.99k views • 52 slides

Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edureka

Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edureka

This Edureka Java Tutorial will help you in understanding the various fundamentals of Java in detail with examples. Below are the topics covered in this tutorial: 1) Introduction to Java 2) Why learn Java? 3) Features of Java 4) How does Java work? 5) Data types in Java 6) Operators in Java 7) Control Statements in Java 8) Arrays in Java 9) Object Oriented Concepts in Java

1.09k views • 55 slides

Object-oriented programming (OOPs) concept in Java

Object-oriented programming (OOPs) concept in Java

Object-oriented programming (OOPs) concept in Java Object-oriented programming: as the name implies, Object-Oriented Programming or OOPs refers to languages that use objects in programming. Object-oriented programming aims to real-world entities, such as inheritance, to hide, to implement polymorphism, etc. in the programming. The main goal of OOP is that data and functions that operate on them, so that no other part of the code to access this data except this feature.

74 views • 3 slides

Object-Oriented Java Programming

Object-Oriented Java Programming

Object-Oriented Java Programming. Why Java?. Simple Platform Independent Safe Multi-Threaded Garbage Collected. Objects, Classes, and Methods. Object Something that occupies memory and has a state Class Pattern (type) of object Method Function and procedure to access object state.

421 views • 38 slides

Java Object-Oriented Programming

668 views • 62 slides

Object-Oriented Programming (Java)

492 views • 46 slides

Object-Oriented Programming (Java)

Object-Oriented Programming (Java). Topics Covered Today. Unit 1.1 Java Applications 1.1.3 Beginning with the Java API 1.1.4 Console I/O. Java API. API stands for Application Programming Interface( 应用程序接口 ) . Java API 是 Java 提供给应用程序的类库,这些库经过仔细的编写,严格地与广泛地测试。

358 views • 33 slides

Java Programming for Beginners to Java Object Oriented Programming Unleashing the Power of Java

Java Programming for Beginners to Java Object Oriented Programming Unleashing the Power of Java

Unlock your career potential with Squad Center Full Stack Java Programming Course. This course is designed to introduce the professionals and students to excel with front-end and back-end Java web developer technologies. So make yourself job-ready with our career services and mentorship by learning to build an end-to-end application, test and deploy code, store data using MongoDB, and much more.

83 views • 7 slides

Java Programming Basics for Beginners

Java Programming Basics for Beginners

Java is a well-known and extensively used computer language and platform. A platform is an environment that makes it easier to write and run programs written in any programming language. Java is efficient, reliable, and secure. In order to become proficient in any programming language, one must first learn the fundamentals of that language. In this blog, weu2019ll explore the fundamental concepts of learn Java and equip you with the knowledge to kickstart your programming career. For more info: https://datavalley.ai/java-programming-basics-for-beginners/

21 views • 18 slides

Java Tutorial

  • Java - Home
  • Java - Overview
  • Java - History
  • Java - Features
  • Java vs C++
  • Java Virtual Machine (JVM)
  • Java - JDK vs JRE vs JVM
  • Java - Hello World Program
  • Java - Environment Setup
  • Java - Basic Syntax
  • Java - Variable Types
  • Java - Data Types
  • Java - Type Casting
  • Java - Unicode System
  • Java - Basic Operators
  • Java - Comments
  • Java - User Input

Java Control Statements

  • Java - Loop Control
  • Java - Decision Making
  • Java - If-else
  • Java - Switch
  • Java - For Loops
  • Java - For-Each Loops
  • Java - While Loops
  • Java - do-while Loops
  • Java - Break
  • Java - Continue

Object Oriented Programming

  • Java - OOPs Concepts
  • Java - Object & Classes
  • Java - Class Attributes
  • Java - Class Methods
  • Java - Methods
  • Java - Variables Scope
  • Java - Constructors
  • Java - Access Modifiers
  • Java - Inheritance
  • Java - Aggregation
  • Java - Polymorphism
  • Java - Overriding
  • Java - Method Overloading
  • Java - Dynamic Binding
  • Java - Static Binding
  • Java - Instance Initializer Block
  • Java - Abstraction
  • Java - Encapsulation
  • Java - Interfaces
  • Java - Packages
  • Java - Inner Classes
  • Java - Static Class
  • Java - Anonymous Class
  • Java - Singleton Class
  • Java - Wrapper Classes
  • Java - Enums
  • Java - Enum Constructor
  • Java - Enum Strings
  • Java - Reflection

Java Built-in Classes

  • Java - Number
  • Java - Boolean
  • Java - Characters
  • Java - Strings
  • Java - Arrays
  • Java - Date & Time
  • Java - Math Class

Java File Handling

  • Java - Files
  • Java - Create a File
  • Java - Write to File
  • Java - Read Files
  • Java - Delete Files
  • Java - Directories
  • Java - I/O Streams

Java Error & Exceptions

  • Java - Exceptions
  • Java - try-catch Block
  • Java - try-with-resources
  • Java - Multi-catch Block
  • Java - Nested try Block
  • Java - Finally Block
  • Java - throw Exception
  • Java - Exception Propagation
  • Java - Built-in Exceptions
  • Java - Custom Exception
  • Java - Annotations
  • Java - Logging
  • Java - Assertions

Java Multithreading

  • Java - Multithreading
  • Java - Thread Life Cycle
  • Java - Creating a Thread
  • Java - Starting a Thread
  • Java - Joining Threads
  • Java - Naming Thread
  • Java - Thread Scheduler
  • Java - Thread Pools
  • Java - Main Thread
  • Java - Thread Priority
  • Java - Daemon Threads
  • Java - Thread Group
  • Java - Shutdown Hook

Java Synchronization

  • Java - Synchronization
  • Java - Block Synchronization
  • Java - Static Synchronization
  • Java - Inter-thread Communication
  • Java - Thread Deadlock
  • Java - Interrupting a Thread
  • Java - Thread Control
  • Java - Reentrant Monitor

Java Networking

  • Java - Networking
  • Java - Socket Programming
  • Java - URL Processing
  • Java - URL Class
  • Java - URLConnection Class
  • Java - HttpURLConnection Class
  • Java - Socket Class
  • Java - ServerSocket Class
  • Java - InetAddress Class
  • Java - Generics

Java Collections

  • Java - Collections
  • Java - Collection Interface

Java Interfaces

  • Java - List Interface
  • Java - Queue Interface
  • Java - Map Interface
  • Java - SortedMap Interface
  • Java - Set Interface
  • Java - SortedSet Interface

Java Data Structures

  • Java - Data Structures
  • Java - Enumeration

Java Collections Algorithms

  • Java - Collections Algorithms
  • Java - Iterators
  • Java - Comparators
  • Java - Comparable Interface in Java

Advanced Java

  • Java - Command-Line Arguments
  • Java - Lambda Expressions
  • Java - Sending Email
  • Java - Applet Basics
  • Java - Javadoc Comments
  • Java - Autoboxing and Unboxing
  • Java - File Mismatch Method
  • Java - REPL (JShell)
  • Java - Multi-Release Jar Files
  • Java - Private Interface Methods
  • Java - Inner Class Diamond Operator
  • Java - Multiresolution Image API
  • Java - Collection Factory Methods
  • Java - Module System
  • Java - Nashorn JavaScript
  • Java - Optional Class
  • Java - Method References
  • Java - Functional Interfaces
  • Java - Default Methods
  • Java - Base64 Encode Decode
  • Java - Switch Expressions
  • Java - Teeing Collectors
  • Java - Microbenchmark
  • Java - Text Blocks
  • Java - Dynamic CDS archive
  • Java - Z Garbage Collector (ZGC)
  • Java - Null Pointer Exception
  • Java - Packaging Tools
  • Java - NUMA Aware G1
  • Java - Sealed Classes
  • Java - Record Classes
  • Java - Hidden Classes
  • Java - Pattern Matching
  • Java - Compact Number Formatting
  • Java - Programming Examples
  • Java - Garbage Collection
  • Java - JIT Compiler

Java Miscellaneous

  • Java - Recursion
  • Java - Regular Expressions
  • Java - Serialization
  • Java - Process API Improvements
  • Java - Stream API Improvements
  • Java - Enhanced @Deprecated Annotation
  • Java - CompletableFuture API Improvements
  • Java - Maths Methods
  • Java - Streams
  • Java - Datetime Api
  • Java 8 - New Features
  • Java 9 - New Features
  • Java 10 - New Features
  • Java 11 - New Features
  • Java 12 - New Features
  • Java 13 - New Features
  • Java 14 - New Features
  • Java 15 - New Features
  • Java 16 - New Features
  • Java - Keywords Reference

Java APIs & Frameworks

  • JDBC Tutorial
  • SWING Tutorial
  • AWT Tutorial
  • Servlets Tutorial
  • JSP Tutorial

Java Class References

  • Java - Scanner Class
  • Java - Arrays Class
  • Java - ArrayList
  • Java - Vector Class
  • Java - Stack Class
  • Java - PriorityQueue
  • Java - Deque Interface
  • Java - LinkedList
  • Java - ArrayDeque
  • Java - HashMap
  • Java - LinkedHashMap
  • Java - WeakHashMap
  • Java - EnumMap
  • Java - TreeMap
  • Java - The IdentityHashMap Class
  • Java - HashSet
  • Java - EnumSet
  • Java - LinkedHashSet
  • Java - TreeSet
  • Java - BitSet Class
  • Java - Dictionary
  • Java - Hashtable
  • Java - Properties
  • Java - Array Methods

Java Useful Resources

  • Java Compiler
  • Java - Questions and Answers
  • Java 8 - Questions and Answers
  • Java - Quick Guide
  • Java - Useful Resources
  • Java - Discussion
  • Java - Examples
  • Selected Reading
  • UPSC IAS Exams Notes
  • Developer's Best Practices
  • Questions and Answers
  • Effective Resume Writing
  • HR Interview Questions
  • Computer Glossary

Java - OOPs (Object-Oriented Programming) Concepts

Oops (object-oriented programming system).

Object means a real-world entity such as a mobile, book, table, computer, watch, etc. Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies software development and maintenance by providing some concepts.

In this tutorial, we will learn about the concepts of Java (OOPs) object-oriented programming systems.

Java OOPs Concepts

Java OOPs (Object-Oriented Programming) Concepts

  • Inheritance
  • Polymorphism
  • Abstraction
  • Encapsulation

In object-oriented programming, an object is an entity that has two characteristics (states and behavior). Some of the real-world objects are book, mobile, table, computer, etc. An object is a variable of the type class, it is a basic component of an object-oriented programming system. A class has the methods and data members (attributes), these methods and data members are accessed through an object. Thus, an object is an instance of a class.

In object-oriented programming, a class is a blueprint from which individual objects are created (or, we can say a class is a data type of an object type). In Java, everything is related to classes and objects. Each class has its methods and attributes that can be accessed and manipulated through the objects.

3. Inheritance

In object-oriented programming, inheritance is a process by which we can reuse the functionalities of existing classes to new classes. In the concept of inheritance, there are two terms base (parent) class and derived (child) class. When a class is inherited from another class (base class), it (derived class) obtains all the properties and behaviors of the base class.

4. Polymorphism

The term "polymorphism" means "many forms". In object-oriented programming, polymorphism is useful when you want to create multiple forms with the same name of a single entity. To implement polymorphism in Java, we use two concepts method overloading and method overriding .

The method overloading is performed in the same class where we have multiple methods with the same name but different parameters, whereas, the method overriding is performed by using the inheritance where we can have multiple methods with the same name in parent and child classes.

5. Abstraction

In object-oriented programming, an abstraction is a technique of hiding internal details and showing functionalities. The abstract classes and interfaces are used to achieve abstraction in Java.

The real-world example of an abstraction is a Car, the internal details such as the engine, process of starting a car, process of shifting gears, etc. are hidden from the user, and features such as the start button, gears, display, break, etc are given to the user. When we perform any action on these features, the internal process works.

6. Encapsulation

In an object-oriented approach, encapsulation is a process of binding the data members (attributes) and methods together. The encapsulation restricts direct access to important data. The best example of the encapsulation concept is making a class where the data members are private and methods are public to access through an object. In this case, only methods can access those private data.

Advantages of Java OOPs

The following are the advantages of using the OOPs in Java:

  • The implementations of OOPs concepts are easier.
  • The execution of the OOPs is faster than procedural-oriented programming.
  • OOPs provide code reusability so that a programmer can reuse an existing code.
  • OOPs help us to keep the important data hidden.

java oop presentation

Flipped classroom.

  • Each week, send an email to all students in the class that briefly describes activities for that week (lectures, reading, and programming assignments drawn from the book or from this booksite).
  • Students watch the lecture videos at their own pace, do the readings, and work on the programming assignments.

Self-study.

Available lectures..

InfoQ Software Architects' Newsletter

A monthly overview of things you need to know as an architect or aspiring architect.

View an example

We protect your privacy.

InfoQ Dev Summit Munich (Sep 26-27): Learn practical strategies to clarify critical development priorities. Summer Sale Now On

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

  • English edition
  • Chinese edition
  • Japanese edition
  • French edition

Back to login

Login with:

Don't have an infoq account, helpful links.

  • About InfoQ
  • InfoQ Editors
  • Write for InfoQ
  • About C4Media

Choose your language

java oop presentation

Get clarity from senior software practitioners on today's critical dev priorities. Register Now.

java oop presentation

Level up your software skills by uncovering the emerging trends you should focus on. Register now.

java oop presentation

Discover emerging trends, insights, and real-world best practices in software development & tech leadership. Join now.

java oop presentation

Your monthly guide to all the topics, technologies and techniques that every professional needs to know about. Subscribe for free.

InfoQ Homepage Presentations It Is Possible to Do Object-Oriented Programming in Java

It Is Possible to Do Object-Oriented Programming in Java

Kevlin Henney takes a philosophical approach to encapsulation, polymorphism and inheritance, and explains what it means to write Java programs according to his view on OOP.

Kevlin is an independent consultant and trainer based in the UK. He has been a columnist for various magazines and web sites, including Better Software, The Register, Application Development Advisor, Java Report and the C/C++ Users Journal, co-author of A Pattern Language for Distributed Computing and On Patterns and Pattern Languages, and editor of the 97 Things Every Programmer Should Know.

About the conference

QCon is a conference that is organized by the community, for the community.The result is a high quality conference experience where a tremendous amount of attention and investment has gone into having the best content on the most important topics presented by the leaders in our community.QCon is designed with the technical depth and enterprise focus of interest to technical team leads, architects, and project managers.

java oop presentation

Recorded at:

java oop presentation

Oct 05, 2011

Kevlin Henney

This content is in the OOP topic

Related topics:.

  • Development
  • Architecture & Design
  • QCon London 2011
  • Methodologies
  • QCon Software Development Conference

Sponsored Content

Related editorial, related sponsored content, [ebook] how to build a software factory to support devsecops, related sponsor.

java oop presentation

Join Red Hat Developer for the software and tutorials to develop cloud applications using Kubernetes, microservices, serverless and Linux.

java oop presentation

IMAGES

  1. PPT

    java oop presentation

  2. PPT

    java oop presentation

  3. PPT

    java oop presentation

  4. PPT

    java oop presentation

  5. PPT

    java oop presentation

  6. Java OOP Presentation

    java oop presentation

VIDEO

  1. OOP

  2. OOP Concepts in Java

  3. JAVA OOP

  4. JAVA OOP

  5. PBT PRESENTATION

  6. 12. Java : OOP Part 5

COMMENTS

  1. oops concept in java

    CPD INDIA. The document discusses key concepts in object-oriented programming in Java including classes, objects, inheritance, packages, interfaces, encapsulation, abstraction, and polymorphism. It provides examples to illustrate each concept. Classes define the structure and behavior of objects. Objects are instances of classes.

  2. OOP Introduction with java programming language

    OOP Introduction with java programming language. This document defines object-oriented programming and compares it to structured programming. It outlines the main principles of OOP including encapsulation, abstraction, inheritance, and polymorphism. Encapsulation binds code and data together for security and consistency.

  3. Lecture 4: Classes and Objects

    Lecture presentation on programming in Java. Topics include: object oriented programming, defining classes, using classes, constructors, methods, accessing fields, primitives versus references, references versus values, and static types and methods.

  4. Object-Oriented-Programming Concepts in Java

    In this article, we'll look into Object-Oriented Programming (OOP) concepts in Java. We'll discuss classes, objects, abstraction, encapsulation, inheritance, and polymorphism. 2. Classes. Classes are the starting point of all objects, and we may consider them as the template for creating objects. A class would typically contain member ...

  5. Advanced Object-Oriented Programming in Java

    Get started. Java is a go-to language for many programmers, and it's a critical skill for any software engineer. After learning Java, picking up other programming languages and advanced concepts becomes much easier. In this book, I'll cover the practical knowledge you need to move from writing basic Java code to.

  6. PDF 03-Object-oriented programming in java

    An object is a bundle of state and behavior. State -the data contained in the object. In Java, these are the fields of the object. Behavior -the actions supported by the object. In Java, these are called methods. Method is just OO-speak for function. Invoke a method = call a function.

  7. Lesson: Object-Oriented Programming Concepts (The Java ...

    Lesson: Object-Oriented Programming Concepts. If you've never used an object-oriented programming language before, you'll need to learn a few basic concepts before you can begin writing any code. This lesson will introduce you to objects, classes, inheritance, interfaces, and packages. Each discussion focuses on how these concepts relate to the ...

  8. Object-Oriented Programming in Java

    Object-oriented programming (OOP) is a fundamental programming paradigm based on the concept of " objects ". These objects can contain data in the form of fields (often known as attributes or properties) and code in the form of procedures (often known as methods). The core concept of the object-oriented approach is to break complex problems ...

  9. Java OOP (Object-Oriented Programming)

    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 ...

  10. Java OOPs Concepts

    OOPs (Object-Oriented Programming System) Object means a real-world entity such as a pen, chair, table, computer, watch, etc. Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies software development and maintenance by providing some concepts: Object. Class.

  11. Object-Oriented Programming Principles in Java: OOP Concepts for Beginners

    Fundamentals of object-oriented programming. Object-oriented programming is a programming paradigm where everything is represented as an object. Objects pass messages to each other. Each object decides what to do with a received message. OOP focuses on each object's states and behaviors.

  12. Object-Oriented Programming (OOP) Using Java

    Object Oriented Programming. Object Oriented Programming. Chapter 2 introduces Object Oriented Programming. OOP is a relatively new approach to programming which supports the creation of new data types and operations to manipulate those types. This presentation introduces OOP. Data Structures and Other Objects. 581 views • 39 slides

  13. Introduction to Object-Oriented Programming with Java

    There are 4 modules in this course. Introduction to OO Programming with Java is course 2 of the Core Java Specialization. After completing this course, you'll be able to create simple Java classes that exhibit the principle of Encapsulation, to import other classes for use, to work with Strings, print output and use advanced math functions.

  14. Object Oriented Programming in Java

    Presentation on theme: "Object Oriented Programming in Java"— Presentation transcript: 1 Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia. 2 Motivation for Object Oriented Programming. Decrease complexity (use layers of abstraction, interfaces, modularity, ...) Reuse existing code, avoid duplication of code Support ...

  15. Introduction to Object Oriented Programming Java.

    Download ppt "Introduction to Object Oriented Programming Java." Similar presentations Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.

  16. Object Oriented Programming_combined.ppt

    Introduction to OOP. Building Blocks of OOP: Objects & Classes. Object: models a. Real world object (ex. computer, book, box) Concept (ex. meeting, interview) Process (ex. sorting a stack of papers or comparing two computers to measure their performance) . Class: prototype or blueprint from which objects are created. Introduction to OOP.

  17. OOPS Concept in JAVA

    In this page, we will learn about basics of OOPs. Object Oriented Programming is a paradigm that. provides many concepts such as inheritance, data. binding, polymorphism etc. 3. OOPS CONSEPTS. Object means a real word entity such as pen, chair, table etc. Object-Oriented Programming is. a methodology or paradigm to design a program.

  18. Oops Concept In Java

    An object in object oriented programming can be physical or conceptual. Conceptual objects are entities that are not tangible in the way real-world physical objects are. Bulb is a physical object. While college is a conceptual object. Conceptual objects may not have a real world equivalent. For instance, a Stack object in a program.

  19. Object-Oriented Programming (OOP) Lecture No. 1

    java oop slides - Free ebook download as Powerpoint Presentation (.ppt), PDF File (.pdf), Text File (.txt) or view presentation slides online. This document provides an overview of an introductory course on object-oriented programming (OOP). The course objectives are to familiarize students with OOP concepts like objects, classes, inheritance, and polymorphism using the Java programming language.

  20. PPT

    This presentation on Java OOPs will give an introduction to Java Object-Oriented Programming. This video explains how to create and use OOP concepts. Whether you are an experienced programmer or not, this channel is intended for everyone who wishes to learn Java programming. You will also learn about all the OOP concepts: Abstraction, Encapsulation, Polymorphism, and Inheritance. And, at the ...

  21. Java

    Java OOPs (Object-Oriented Programming) Concepts. 1. Object. In object-oriented programming, an object is an entity that has two characteristics (states and behavior). Some of the real-world objects are book, mobile, table, computer, etc. An object is a variable of the type class, it is a basic component of an object-oriented programming system.

  22. Lectures

    Our examples involve abstractions such as color, images, and genes. This style of programming is known as object-oriented programming because our programs manipulate objects, which hold data type values. Lecture 9: Creating Data Types. Creating your own data types is the central activity in modern Java programming.

  23. It Is Possible to Do Object-Oriented Programming in Java

    Kevlin Henney takes a philosophical approach to encapsulation, polymorphism and inheritance, and explains what it means to write Java programs according to his view on OOP. Bio Kevlin is an ...