SlideShare a Scribd company logo
Object Oriented
Visual Programming
ABSTRACTION
ABSTRACTION
▰ Abstraction is one of the key concepts of object-oriented
programming (OOP) languages.
▰ Its main goal is to handle complexity by hiding unnecessary
details from the user. That enables the user to implement more
complex logic on top of the provided abstraction without
understanding or even thinking about all the hidden complexity.
▰ In Java programming, abstraction is achieved using Abstract
classes and interfaces.
WHAT IS ABSTRACTIONS?
▰ Abstraction refers to the act of representing essential features without including the
background details or explanations.
▰ Abstraction lets you focus on what the object does instead of how it does it.
▰ Therefore, it is an art to simplify things from outsiders.
▰ The abstraction in Java can be achieved by:
▻ Abstract Class : partial or total abstraction
▻ Interface : total abstraction
▰ Since classes use the concept of data abstraction, they are known as Abstract Data Types
(ADT).
WHY ABSTRACTIONS?
▰ easier to think about - hide what doesn't matter
▰ protection - prevent access to things you shouldn't see
▰ plug compatibility
▻ replacement of pieces, often without recompilation,
definitely without rewriting libraries
▻ division of labor in software projects
Abstraction vs Encapsulation
▰ Abstraction = Implementation Hiding.
hiding the details and implementation of the code from
outside world.
▰ Encapsulation = Information Hiding.
hiding the hiding the data and controlling the visibility of the
code.
Abstract Classes
▰ A class declared as abstract is known as abstract class.
▰ An abstract class must be declared with an abstract keyword.
▰ It cannot be instantiated.
▰ It needs to be extended to be used.
▰ It must contain at least 1 abstract method declaration.
▰ It may contain constructors, non-abstract, static and/or final
methods as well. Otherwise, fully abstraction concept will be
achieved.
Declaring an Abstract Class
▰ To declare an abstract class, you simply use the abstract keyword
before the class keyword.
Declaring an Abstract Class
▰ To declare an abstract class, you simply use the abstract keyword
before the class keyword. Here’s a basic example:
In this code snippet, we’ve declared an abstract class Vehicle with an abstract
method run(). This method doesn’t have a body – it’s just a declaration. That’s
because the implementation of this method is provided by the class that extends
this abstract class
Syntax of Abstract Method
▰ The syntax for the abstract method is similar to any user-defined
method in Java except you have to add abstract keyword at the
start of the declaration.
▰ For example
Abstract Class in Java
To make an abstract class, you must declare a class with an abstract
keyword.
An abstract class may have a mixed set of abstract and regular(non-abstract)
methods.
Abstract Class in Java
When a regular class extends an abstract class, it must implement
the abstract methods of an abstract class, or a compile error is
issued.
Abstract Class in Java
You can even create an abstract class which only contains concrete
regular methods and no abstract methods.
Abstract Class in Java
You must declare a class with the abstract keyword, even when there
is only a single abstract method in it.
Abstract Class in Java
Abstract Class in Java
Example
This example creates an abstract class
called "Shapes"
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
This example creates an abstract class Animal with abstract
methods eat() and sleep(). Create subclasses Lion, Tiger, and
Deer that extend the Animal class and implement the eat() and
sleep() methods differently based on their specific behavior.
Abstract Class in Java
Example
▰ In this program, the Animal class is an abstract class that
defines the abstract methods eat() and sleep().
▰ The Lion, Tiger, and Deer classes extend the Animal class and
provide their own implementations for the eat() and sleep()
methods based on their specific behavior.
▰ The Main class demonstrates the usage of these classes by
creating objects of each subclass and invoking the eat() and
sleep() methods accordingly.
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
INTERFACE
▰ An interface is a 100% abstract class which is declared with
the interface keyword. Methods of an interface are implicitly
abstract, hence when declaring an interface, you must not
provide an implementation of any of its methods and its
methods should end with a semicolon ;
▰ Interface methods are implicitly declared with the public access
modifier and abstract keyword, which means that even if you
don't explicitly type public and abstract with interface methods,
they are still always public and abstract, by default.
INTERFACE
▰ A class can implement an
interface by providing the
internal logic of all methods of
an interface, conforming to
each of their method
signatures. To implement an
interface, a class must use the
implements keyword.
INTERFACE
▰ You cannot instantiate or create an object of an interface, because it is a 100%
abstract and skeletal. Hence, instantiating an interface gives a compile error.
INTERFACE
▰ A class can
implement multiple
interfaces and it
must provide an
implementation of
all their methods.
INTERFACE
▰ An abstract class
can implement
an interface and
it doesn't have to
implement its
methods.
INTERFACE
ABSTRACT VS INTERFACE
This example create an interface Shape with the getArea()
method. Create three classes Rectangle, Circle, and Triangle that
implement the Shape interface. Implement the getArea() method
for each of the three classes.
Interface in Java Example
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
Exercises
▰ Write a Java program to create an abstract class Shape3D with
abstract methods calculateVolume() and
calculateSurfaceArea(). Create subclasses Sphere and Cube
that extend the Shape3D class and implement the respective
methods to calculate the volume and surface area of each
shape.

More Related Content

Similar to 06_OOVP.pptx object oriented and visual programming (20)

PPTX
abstract,final,interface (1).pptx upload
dashpayal697
 
PDF
java-06inheritance
Arjun Shanka
 
PDF
Exception handling and packages.pdf
Kp Sharma
 
PPTX
Abstraction in java [abstract classes and Interfaces
Ahmed Nobi
 
PPT
Java interfaces & abstract classes
Shreyans Pathak
 
PPTX
Lecture 18
talha ijaz
 
PPT
A1869984431_21789_28_2018_Abstract Class.ppt
RithwikRanjan
 
PPTX
Abstract Class & Abstract Method in Core Java
MOHIT AGARWAL
 
DOCX
Core java notes with examples
bindur87
 
PDF
Java 06
Loida Igama
 
PPT
06 abstract-classes
Abhishek Khune
 
PPTX
Abstraction encapsulation inheritance polymorphism
PriyadharshiniG41
 
PPTX
A class which is declared with the abstract keyword is known as an abstract c...
Kavitha S
 
PPTX
Java presentation
Akteruzzaman .
 
PPT
9 abstract interface
Abhijit Gaikwad
 
PPT
Abstract_descrption
Mahi Mca
 
PPTX
Abstract class and Interface
Haris Bin Zahid
 
PPTX
Abstraction1
zindadili
 
PPTX
Lec 1.9 oop
Badar Waseer
 
PPT
06 abstract-classes
Anup Burange
 
abstract,final,interface (1).pptx upload
dashpayal697
 
java-06inheritance
Arjun Shanka
 
Exception handling and packages.pdf
Kp Sharma
 
Abstraction in java [abstract classes and Interfaces
Ahmed Nobi
 
Java interfaces & abstract classes
Shreyans Pathak
 
Lecture 18
talha ijaz
 
A1869984431_21789_28_2018_Abstract Class.ppt
RithwikRanjan
 
Abstract Class & Abstract Method in Core Java
MOHIT AGARWAL
 
Core java notes with examples
bindur87
 
Java 06
Loida Igama
 
06 abstract-classes
Abhishek Khune
 
Abstraction encapsulation inheritance polymorphism
PriyadharshiniG41
 
A class which is declared with the abstract keyword is known as an abstract c...
Kavitha S
 
Java presentation
Akteruzzaman .
 
9 abstract interface
Abhijit Gaikwad
 
Abstract_descrption
Mahi Mca
 
Abstract class and Interface
Haris Bin Zahid
 
Abstraction1
zindadili
 
Lec 1.9 oop
Badar Waseer
 
06 abstract-classes
Anup Burange
 

Recently uploaded (20)

PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PPTX
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PPTX
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PPT
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
PPTX
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
Design Thinking basics for Engineers.pdf
CMR University
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
Ad

06_OOVP.pptx object oriented and visual programming

  • 2. ABSTRACTION ▰ Abstraction is one of the key concepts of object-oriented programming (OOP) languages. ▰ Its main goal is to handle complexity by hiding unnecessary details from the user. That enables the user to implement more complex logic on top of the provided abstraction without understanding or even thinking about all the hidden complexity. ▰ In Java programming, abstraction is achieved using Abstract classes and interfaces.
  • 3. WHAT IS ABSTRACTIONS? ▰ Abstraction refers to the act of representing essential features without including the background details or explanations. ▰ Abstraction lets you focus on what the object does instead of how it does it. ▰ Therefore, it is an art to simplify things from outsiders. ▰ The abstraction in Java can be achieved by: ▻ Abstract Class : partial or total abstraction ▻ Interface : total abstraction ▰ Since classes use the concept of data abstraction, they are known as Abstract Data Types (ADT).
  • 4. WHY ABSTRACTIONS? ▰ easier to think about - hide what doesn't matter ▰ protection - prevent access to things you shouldn't see ▰ plug compatibility ▻ replacement of pieces, often without recompilation, definitely without rewriting libraries ▻ division of labor in software projects
  • 5. Abstraction vs Encapsulation ▰ Abstraction = Implementation Hiding. hiding the details and implementation of the code from outside world. ▰ Encapsulation = Information Hiding. hiding the hiding the data and controlling the visibility of the code.
  • 6. Abstract Classes ▰ A class declared as abstract is known as abstract class. ▰ An abstract class must be declared with an abstract keyword. ▰ It cannot be instantiated. ▰ It needs to be extended to be used. ▰ It must contain at least 1 abstract method declaration. ▰ It may contain constructors, non-abstract, static and/or final methods as well. Otherwise, fully abstraction concept will be achieved.
  • 7. Declaring an Abstract Class ▰ To declare an abstract class, you simply use the abstract keyword before the class keyword.
  • 8. Declaring an Abstract Class ▰ To declare an abstract class, you simply use the abstract keyword before the class keyword. Here’s a basic example: In this code snippet, we’ve declared an abstract class Vehicle with an abstract method run(). This method doesn’t have a body – it’s just a declaration. That’s because the implementation of this method is provided by the class that extends this abstract class
  • 9. Syntax of Abstract Method ▰ The syntax for the abstract method is similar to any user-defined method in Java except you have to add abstract keyword at the start of the declaration. ▰ For example
  • 10. Abstract Class in Java To make an abstract class, you must declare a class with an abstract keyword.
  • 11. An abstract class may have a mixed set of abstract and regular(non-abstract) methods. Abstract Class in Java
  • 12. When a regular class extends an abstract class, it must implement the abstract methods of an abstract class, or a compile error is issued. Abstract Class in Java
  • 13. You can even create an abstract class which only contains concrete regular methods and no abstract methods. Abstract Class in Java
  • 14. You must declare a class with the abstract keyword, even when there is only a single abstract method in it. Abstract Class in Java
  • 15. Abstract Class in Java Example This example creates an abstract class called "Shapes"
  • 19. This example creates an abstract class Animal with abstract methods eat() and sleep(). Create subclasses Lion, Tiger, and Deer that extend the Animal class and implement the eat() and sleep() methods differently based on their specific behavior. Abstract Class in Java Example
  • 20. ▰ In this program, the Animal class is an abstract class that defines the abstract methods eat() and sleep(). ▰ The Lion, Tiger, and Deer classes extend the Animal class and provide their own implementations for the eat() and sleep() methods based on their specific behavior. ▰ The Main class demonstrates the usage of these classes by creating objects of each subclass and invoking the eat() and sleep() methods accordingly.
  • 27. INTERFACE ▰ An interface is a 100% abstract class which is declared with the interface keyword. Methods of an interface are implicitly abstract, hence when declaring an interface, you must not provide an implementation of any of its methods and its methods should end with a semicolon ;
  • 28. ▰ Interface methods are implicitly declared with the public access modifier and abstract keyword, which means that even if you don't explicitly type public and abstract with interface methods, they are still always public and abstract, by default. INTERFACE
  • 29. ▰ A class can implement an interface by providing the internal logic of all methods of an interface, conforming to each of their method signatures. To implement an interface, a class must use the implements keyword. INTERFACE
  • 30. ▰ You cannot instantiate or create an object of an interface, because it is a 100% abstract and skeletal. Hence, instantiating an interface gives a compile error. INTERFACE
  • 31. ▰ A class can implement multiple interfaces and it must provide an implementation of all their methods. INTERFACE
  • 32. ▰ An abstract class can implement an interface and it doesn't have to implement its methods. INTERFACE
  • 34. This example create an interface Shape with the getArea() method. Create three classes Rectangle, Circle, and Triangle that implement the Shape interface. Implement the getArea() method for each of the three classes. Interface in Java Example
  • 43. Exercises ▰ Write a Java program to create an abstract class Shape3D with abstract methods calculateVolume() and calculateSurfaceArea(). Create subclasses Sphere and Cube that extend the Shape3D class and implement the respective methods to calculate the volume and surface area of each shape.