SlideShare a Scribd company logo
1 of 19
Download to read offline
ANDROID COURSE
WITH JAVA
Developed by Keroles Magdy
keroles.m.yacoub@gmail.com
2019 ©
Session topics :-
• Inheritance.
• Super Keyword.
• Polymorphism.
• Abstraction.
• Interface.
Inheritance :-
• Inheritance, process where one class acquires the properties (methods and
fields) of another.
• Final class, is simply a class that can't be extended.
• subclass (child) - the class that inherits from another class
• superclass (parent) - the class being inherited from
• Syntax :
class Parent{
.....
}
class Son extends Parent{
.....
}
Inheritance :-
• EX :
class Employee{
float salary=40000;
}
class Programmer extends Employee{
int bonus=10000;
public static void main(String args[]){
Programmer p=new Programmer();
System.out.println("Programmer salary is:"+p.salary);
System.out.println("Bonus of Programmer is:"+p.bonus);
}
}
Inheritance :-
• Types of inheritance :
Class A Class AClass A
Class B
Class C
class B Class B Class C
Single
Multilevel
Hierarchical
Inheritance :-
• Types of inheritance :
Class A class B
class C
Multiple
Class A
Class B Class C
Hybrid
Class E
Super Keyword :-
• Super, a keyword that can be used to refer immediate parent class
instance variable, method, constructor.
• Super Variable EX :
class Animal{
String color="white";
}
class Dog extends Animal{
String color="black";
void printColor(){
System.out.println(color)
System.out.println(super.color);//prints color of Animal class
}
}
Super Keyword :-
• Super Method EX :
class Animal{
void eat(){System.out.println("eating...");}
}
class Dog extends Animal{
void eat(){System.out.println("eating bread...");}
void bark(){System.out.println("barking...");}
void work(){
super.eat();
bark();
}
}
Super Keyword :-
• Super Constructor EX :
class Animal{
Animal(){System.out.println("animal is created");}
}
class Dog extends Animal{
Dog(){
super();
System.out.println("dog is created");
}
}
Polymorphism :-
• Compile-time polymorphism is called ‘overloading’.
• Overload, Assigning a new meaning to the function/operator.
• Overloaded functions differ in regards to, different ‘number or type of
parameter(s)’, it makes one overloaded function distinct from another. In
this way, the compiler recognizes which overloaded function is being
called.
Polymorphism :-
• EX :
• Overload EX :
float Add(int x, float y){
return x+y;
}
_____________________
int Add(int x, int y){
return x+y;
}
Polymorphism :-
• EX:
• Overload EX :
float Add(float x, int y){
return x+y;
}
_____________________
double Add(int x, float y,double z){
return x+y+z;
}
Polymorphism :-
• Polymorphism achieved during run-time is called ‘overriding’.
• Override, Replacing the meaning of existing function/operator.
• Final method, it cannot be overridden.
• EX :
public void move(){
System.out.println("vehicle move");
}
@Override
public void move(){
System.out.println("Car move");
}
Break
Abstraction :-
• Abstraction, is the process of hiding certain details and showing only
essential information to the user achieved with either abstract classes or
interfaces.
• It is a non-access modifier, used for classes and methods
• Abstract class: is a restricted class that cannot be used to create objects (to
access it, it must be inherited from another class).
• Abstract method: can only be used in an abstract class, and it does not
have a body. The body is provided by the subclass.
Abstraction :-
• EX :
abstract class Sum{
public abstract int sumOfTwo(int n1, int n2);
public abstract int sumOfThree(int n1, int n2, int n3);
public void disp(){
System.out.println("Sum");
}
}
Interface :-
• Interface, is a blueprint of a class and contains a collection of abstract
methods.
class
class
interface
class
interface
interface
extends implements extends
Interface :-
• EX :
interface Bank{
float rateOfInterest();
}
class SBI implements Bank{
public float rateOfInterest(){return 9.15f;}
}
the End

More Related Content

Similar to Android course session 4 ( OOP ) part 2

Similar to Android course session 4 ( OOP ) part 2 (20)

Bc0037
Bc0037Bc0037
Bc0037
 
Chapter 04 inheritance
Chapter 04 inheritanceChapter 04 inheritance
Chapter 04 inheritance
 
Java - Inheritance_multiple_inheritance.pptx
Java - Inheritance_multiple_inheritance.pptxJava - Inheritance_multiple_inheritance.pptx
Java - Inheritance_multiple_inheritance.pptx
 
PROGRAMMING IN JAVA
PROGRAMMING IN JAVAPROGRAMMING IN JAVA
PROGRAMMING IN JAVA
 
04 Java Language And OOP Part IV
04 Java Language And OOP Part IV04 Java Language And OOP Part IV
04 Java Language And OOP Part IV
 
2CPP07 - Inheritance
2CPP07 - Inheritance2CPP07 - Inheritance
2CPP07 - Inheritance
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the Horizon
 
Polymorphism Using C++
Polymorphism Using C++Polymorphism Using C++
Polymorphism Using C++
 
3. Polymorphism.pptx
3. Polymorphism.pptx3. Polymorphism.pptx
3. Polymorphism.pptx
 
Inheritance
InheritanceInheritance
Inheritance
 
‫Chapter3 inheritance
‫Chapter3 inheritance‫Chapter3 inheritance
‫Chapter3 inheritance
 
Polymorphism and Virtual Functions ppt bioinformatics
Polymorphism and Virtual Functions ppt bioinformaticsPolymorphism and Virtual Functions ppt bioinformatics
Polymorphism and Virtual Functions ppt bioinformatics
 
Inheritance1
Inheritance1Inheritance1
Inheritance1
 
Polymorphism ppt
Polymorphism pptPolymorphism ppt
Polymorphism ppt
 
Polymorphism & inheritence ppt
Polymorphism & inheritence pptPolymorphism & inheritence ppt
Polymorphism & inheritence ppt
 
full defination of final opp.pptx
full defination of final opp.pptxfull defination of final opp.pptx
full defination of final opp.pptx
 
C++ L10-Inheritance
C++ L10-InheritanceC++ L10-Inheritance
C++ L10-Inheritance
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
 

Recently uploaded

TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 

Android course session 4 ( OOP ) part 2

  • 1. ANDROID COURSE WITH JAVA Developed by Keroles Magdy keroles.m.yacoub@gmail.com 2019 ©
  • 2. Session topics :- • Inheritance. • Super Keyword. • Polymorphism. • Abstraction. • Interface.
  • 3. Inheritance :- • Inheritance, process where one class acquires the properties (methods and fields) of another. • Final class, is simply a class that can't be extended. • subclass (child) - the class that inherits from another class • superclass (parent) - the class being inherited from • Syntax : class Parent{ ..... } class Son extends Parent{ ..... }
  • 4. Inheritance :- • EX : class Employee{ float salary=40000; } class Programmer extends Employee{ int bonus=10000; public static void main(String args[]){ Programmer p=new Programmer(); System.out.println("Programmer salary is:"+p.salary); System.out.println("Bonus of Programmer is:"+p.bonus); } }
  • 5. Inheritance :- • Types of inheritance : Class A Class AClass A Class B Class C class B Class B Class C Single Multilevel Hierarchical
  • 6. Inheritance :- • Types of inheritance : Class A class B class C Multiple Class A Class B Class C Hybrid Class E
  • 7. Super Keyword :- • Super, a keyword that can be used to refer immediate parent class instance variable, method, constructor. • Super Variable EX : class Animal{ String color="white"; } class Dog extends Animal{ String color="black"; void printColor(){ System.out.println(color) System.out.println(super.color);//prints color of Animal class } }
  • 8. Super Keyword :- • Super Method EX : class Animal{ void eat(){System.out.println("eating...");} } class Dog extends Animal{ void eat(){System.out.println("eating bread...");} void bark(){System.out.println("barking...");} void work(){ super.eat(); bark(); } }
  • 9. Super Keyword :- • Super Constructor EX : class Animal{ Animal(){System.out.println("animal is created");} } class Dog extends Animal{ Dog(){ super(); System.out.println("dog is created"); } }
  • 10. Polymorphism :- • Compile-time polymorphism is called ‘overloading’. • Overload, Assigning a new meaning to the function/operator. • Overloaded functions differ in regards to, different ‘number or type of parameter(s)’, it makes one overloaded function distinct from another. In this way, the compiler recognizes which overloaded function is being called.
  • 11. Polymorphism :- • EX : • Overload EX : float Add(int x, float y){ return x+y; } _____________________ int Add(int x, int y){ return x+y; }
  • 12. Polymorphism :- • EX: • Overload EX : float Add(float x, int y){ return x+y; } _____________________ double Add(int x, float y,double z){ return x+y+z; }
  • 13. Polymorphism :- • Polymorphism achieved during run-time is called ‘overriding’. • Override, Replacing the meaning of existing function/operator. • Final method, it cannot be overridden. • EX : public void move(){ System.out.println("vehicle move"); } @Override public void move(){ System.out.println("Car move"); }
  • 14. Break
  • 15. Abstraction :- • Abstraction, is the process of hiding certain details and showing only essential information to the user achieved with either abstract classes or interfaces. • It is a non-access modifier, used for classes and methods • Abstract class: is a restricted class that cannot be used to create objects (to access it, it must be inherited from another class). • Abstract method: can only be used in an abstract class, and it does not have a body. The body is provided by the subclass.
  • 16. Abstraction :- • EX : abstract class Sum{ public abstract int sumOfTwo(int n1, int n2); public abstract int sumOfThree(int n1, int n2, int n3); public void disp(){ System.out.println("Sum"); } }
  • 17. Interface :- • Interface, is a blueprint of a class and contains a collection of abstract methods. class class interface class interface interface extends implements extends
  • 18. Interface :- • EX : interface Bank{ float rateOfInterest(); } class SBI implements Bank{ public float rateOfInterest(){return 9.15f;} }