SlideShare a Scribd company logo
Abstraction in Java
Abstraction in Java
• Abstraction is a process of hiding the implementation details and
showing only functionality to the user.
• For example, sending SMS where you type the text and send the
message. You don't know the internal processing about the message
delivery.
Ways to achieve Abstraction
• There are two ways to achieve abstraction in java.
1. Abstract class (0 to 100%)
2. Interface (100%)
1. Abstract class in Java
• A class which is declared as keyword abstract is known as an abstract
class.
• It can have abstract and non-abstract methods.
Points to Remember
• An abstract class must be declared with an abstract keyword.
• It can have abstract and non-abstract methods.
• We can not create the object of abstract class.
Cont…
• It needs to be extended in another class and its abstract method should
be implemented in that class.
Example of abstract class
abstract class A
{
}
Abstract Method in Java
• A method which is declared as abstract and does not have body is
known as an abstract method.
• Example of abstract method
abstract void A();//no method body and abstract
Example
abstract class A
{
abstract void run();
void display()
{
System.out.println("Bike");
}
}
class B extends A
{
void run()
{
System.out.println("running safely");
}
public static void main(String args[])
{
B b1 = new B();
b1.run();
b1. display();
}
}
Cont…
Output:
running safely
Bike
2. Interface in Java
• It has only abstract methods, not method with body.
• It is used to achieve 100 % abstraction and multiple inheritance in
Java.
Why use Java interface?
• It is used to achieve 100% abstraction.
• By interface, we can support the functionality of multiple inheritance.
Note:
• Like abstract classes, object of interfaces can not be created.
• It needs to be implements in a class and its method should be
implemented in that class.
• Interface methods are by default abstract and public.
Cont…
• Interface attributes are by default public, static and final.
Example:
Example
interface A
{
void print();
}
class B implements A
{
public void print()
{
System.out.println("Hello");
}
public static void main(String a[])
{
B b1 = new B();
b1.print();
}
}
Cont…
Output:
Hello
Multiple inheritance with the help of Interface
interface X
{
void display();
}
interface Y
{
void display();
}
class C implements X, Y
{
public void display()
{
System.out.println("Hello");
}
public static void main(String x[])
{
C c1 = new C();
c1.display();
}
}
Output:
Hello

More Related Content

PPTX
A class which is declared with the abstract keyword is known as an abstract c...
Kavitha S
 
PPT
Abstract class in java
Lovely Professional University
 
PPT
ABSTRACT CLASSES AND INTERFACES.ppt
JayanthiM15
 
PPTX
Lecture-on-Object-Oriented-Programming-Language-Java.pptx
officialpriyanshu228
 
PPT
12.2 Abstract class and Interface.ppt
VISHNUSHANKARSINGH3
 
PPTX
Abstract class
PhD Research Scholar
 
PPTX
8abstact class in c#
Sireesh K
 
PDF
Abstraction in Java: Abstract class and Interfaces
Jamsher bhanbhro
 
A class which is declared with the abstract keyword is known as an abstract c...
Kavitha S
 
Abstract class in java
Lovely Professional University
 
ABSTRACT CLASSES AND INTERFACES.ppt
JayanthiM15
 
Lecture-on-Object-Oriented-Programming-Language-Java.pptx
officialpriyanshu228
 
12.2 Abstract class and Interface.ppt
VISHNUSHANKARSINGH3
 
Abstract class
PhD Research Scholar
 
8abstact class in c#
Sireesh K
 
Abstraction in Java: Abstract class and Interfaces
Jamsher bhanbhro
 

Similar to BCA Abstraction.pptx (20)

PPTX
Abstraction in java.pptx
AsifMulani17
 
PDF
Exception handling and packages.pdf
Kp Sharma
 
PPT
A1869984431_21789_28_2018_Abstract Class.ppt
RithwikRanjan
 
DOCX
Core java notes with examples
bindur87
 
PPTX
Objects and classes in OO Programming concepts
researchveltech
 
PPTX
More oop in java
SAGARDAVE29
 
PPSX
OOP with Java - Abstract Classes and Interfaces
Hitesh-Java
 
PPTX
Abstract class and interface
Mazharul Sabbir
 
PPTX
OOP with Java - Abstract Classes and Interfaces
RatnaJava
 
PDF
Abstract Class and Interface.pdf
rajaratna4
 
PPTX
Session 10 - OOP with Java - Abstract Classes and Interfaces
PawanMM
 
PPTX
Abstract Class and Interface for Java Intoductory course.pptx
DrShamimAlMamun
 
PPTX
abstract,final,interface (1).pptx upload
dashpayal697
 
PPTX
Abstract Class & Abstract Method in Core Java
MOHIT AGARWAL
 
PPTX
Java 6.pptx
usmanusman720379
 
PPTX
it is the quick gest about the interfaces in java
arunkumarg271
 
PPTX
INTERFACES. with machine learning and data
dineshkesav07
 
PPTX
Abstraction encapsulation inheritance polymorphism
PriyadharshiniG41
 
PPTX
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Simplilearn
 
PPTX
abstract classes and interfaces in c++\ by M adnan Haider MNSUAM.pptx
haiderkhooradnan
 
Abstraction in java.pptx
AsifMulani17
 
Exception handling and packages.pdf
Kp Sharma
 
A1869984431_21789_28_2018_Abstract Class.ppt
RithwikRanjan
 
Core java notes with examples
bindur87
 
Objects and classes in OO Programming concepts
researchveltech
 
More oop in java
SAGARDAVE29
 
OOP with Java - Abstract Classes and Interfaces
Hitesh-Java
 
Abstract class and interface
Mazharul Sabbir
 
OOP with Java - Abstract Classes and Interfaces
RatnaJava
 
Abstract Class and Interface.pdf
rajaratna4
 
Session 10 - OOP with Java - Abstract Classes and Interfaces
PawanMM
 
Abstract Class and Interface for Java Intoductory course.pptx
DrShamimAlMamun
 
abstract,final,interface (1).pptx upload
dashpayal697
 
Abstract Class & Abstract Method in Core Java
MOHIT AGARWAL
 
Java 6.pptx
usmanusman720379
 
it is the quick gest about the interfaces in java
arunkumarg271
 
INTERFACES. with machine learning and data
dineshkesav07
 
Abstraction encapsulation inheritance polymorphism
PriyadharshiniG41
 
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Simplilearn
 
abstract classes and interfaces in c++\ by M adnan Haider MNSUAM.pptx
haiderkhooradnan
 
Ad

More from sarthakgithub (10)

PPTX
Access Modifiers in Java.pptx
sarthakgithub
 
PPTX
ppt-2.pptx
sarthakgithub
 
PPTX
soumay.pptx
sarthakgithub
 
PPTX
Data Path Design and Bus Organization.pptx
sarthakgithub
 
PPTX
Python Unit II.pptx
sarthakgithub
 
PPTX
OOP-Module-1-Section-4-LectureNo1-5.pptx
sarthakgithub
 
PPT
Flow Control (1).ppt
sarthakgithub
 
PPT
BCA MultiThreading.ppt
sarthakgithub
 
PPTX
BCA Final Keyword.pptx
sarthakgithub
 
PPTX
BCA Super Keyword.pptx
sarthakgithub
 
Access Modifiers in Java.pptx
sarthakgithub
 
ppt-2.pptx
sarthakgithub
 
soumay.pptx
sarthakgithub
 
Data Path Design and Bus Organization.pptx
sarthakgithub
 
Python Unit II.pptx
sarthakgithub
 
OOP-Module-1-Section-4-LectureNo1-5.pptx
sarthakgithub
 
Flow Control (1).ppt
sarthakgithub
 
BCA MultiThreading.ppt
sarthakgithub
 
BCA Final Keyword.pptx
sarthakgithub
 
BCA Super Keyword.pptx
sarthakgithub
 
Ad

Recently uploaded (20)

PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
DOCX
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PPTX
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PDF
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 

BCA Abstraction.pptx

  • 2. Abstraction in Java • Abstraction is a process of hiding the implementation details and showing only functionality to the user. • For example, sending SMS where you type the text and send the message. You don't know the internal processing about the message delivery.
  • 3. Ways to achieve Abstraction • There are two ways to achieve abstraction in java. 1. Abstract class (0 to 100%) 2. Interface (100%)
  • 4. 1. Abstract class in Java • A class which is declared as keyword abstract is known as an abstract class. • It can have abstract and non-abstract methods.
  • 5. Points to Remember • An abstract class must be declared with an abstract keyword. • It can have abstract and non-abstract methods. • We can not create the object of abstract class.
  • 6. Cont… • It needs to be extended in another class and its abstract method should be implemented in that class.
  • 7. Example of abstract class abstract class A { }
  • 8. Abstract Method in Java • A method which is declared as abstract and does not have body is known as an abstract method. • Example of abstract method abstract void A();//no method body and abstract
  • 9. Example abstract class A { abstract void run(); void display() { System.out.println("Bike"); } } class B extends A { void run() { System.out.println("running safely"); } public static void main(String args[]) { B b1 = new B(); b1.run(); b1. display(); } }
  • 11. 2. Interface in Java • It has only abstract methods, not method with body. • It is used to achieve 100 % abstraction and multiple inheritance in Java.
  • 12. Why use Java interface? • It is used to achieve 100% abstraction. • By interface, we can support the functionality of multiple inheritance.
  • 13. Note: • Like abstract classes, object of interfaces can not be created. • It needs to be implements in a class and its method should be implemented in that class. • Interface methods are by default abstract and public.
  • 14. Cont… • Interface attributes are by default public, static and final. Example:
  • 15. Example interface A { void print(); } class B implements A { public void print() { System.out.println("Hello"); } public static void main(String a[]) { B b1 = new B(); b1.print(); } }
  • 17. Multiple inheritance with the help of Interface interface X { void display(); } interface Y { void display(); } class C implements X, Y { public void display() { System.out.println("Hello"); } public static void main(String x[]) { C c1 = new C(); c1.display(); } } Output: Hello