SlideShare ist ein Scribd-Unternehmen logo
1 von 4
Downloaden Sie, um offline zu lesen
Core Java

Debasish Pratihari

Inheritance :




Object oriented programming allows classes to
inherit commonly used state and behavior from
other class through inheritance.
Allows a class to acquire the members of another
class.



Parent-child/super-sub relationship is established.



Child can not restrict the scope of inheritance.



By default java classes are sub class of Object class
directly or indirectly.

 Java does not
supports multiple
inheritance.

Parent/super decide the members that can be
inherited by access specifiers.



Note:
 Java uses a keyword
extends to inherit.



Primarily solves two purposes. Re-usability and
Providing a generic behavior.



A super class reference can refer to any object of its
subclass.



If signature of a function in the super class is same
as the signature of a function in the sub-class then
the function is said to be over-ridden and it can’t be
called by the object of sub class.



Any other class reference can be assigned to Object
Class object.



 If a function is
declared as final it
can’t be over-ridden.

Incase of a child class member having the same
name as of a parent class member then the parent
class member is suppresses. And then to call those
parent class members we have to use the super
keyword.



 If a class is final
then it is restricted
to be inherited.

Compiler attaches a word super() as the first line of
the constructor by default which calls the no-args
constructor of the parent.



Note :

Super object always holds address/reference of
parent class.

Lecture/core/oops3/10

Page #1

feel the Technology…
Core Java

Debasish Pratihari

Abstract Class:


An abstract class is specifically designed to be
inherited only. i.e. it can’t be instantiated.
However it can be used to create object
reference.



A class can be made Abstract by using the
keyword “abstract”



If a class contains any abstract method then it
must be declared as abstract.



A abstract class may have fully defined methods
(concrete methods) also.

Abstract Method:


Abstract methods are not concrete methods.



They need to be override by the subclasses.



An abstract method force to declare its class as
abstract.

Example :
abstract class Shape{
abstract void getData();
void aboutUs(){
System.out.println(“Developed by Debasish at Lakshya”);
}
}
class Circle extends Shape{
void getData(){
//method definition here
}
}

Lecture/core/oops3/10

Page #2

feel the Technology…
Core Java

Debasish Pratihari

Interface:


Using the keyword interface, you can fully abstract a
class interface from its implementation.



Using interface, you can specify what a class must
do, but not how it does it.



Interfaces are lack of instance variable, and their
methods are declared without any body



A class can implement any number of interfaces



To implement an interface, a class must create a
complete set of methods defined by the interface.



All the variables of an interface are public, static and
final .All methods are abstract.



The methods of a class that implements can
interface must be declared public.



It is both permissible and common for classes that
implement interfaces to define additional members
of their own.



You can declare variables as object reference that
uses an interface rather than a class type. Any
instance of any class that implements the declared
interface can be referred to by such variable.



An interface reference variable only has knowledge
of the methods declared by its interface declaration



If a class includes an interface but does not fully
implement the methods defined by that interface,
than that class must be declared as abstract



One interface can inherit another interface by use of
the keyword extends.



When a class implements an interface that inherits
another interface, it must provide implementation for
all the methods defined within the interface
inheritance chain.

Lecture/core/oops3/10

Page #3

feel the Technology…
Core Java

Debasish Pratihari

Nested, Inner and Anonymous Classes:


A class can be defined inside another class, called
nested class.



Its scope is limited within its enclosing class.



A nested class can access all the members of its
enclosing class including private members. But the
enclosing class can’t access any member of the
nested class.



The nested class can be static or non-static



A static nested class can access the members of its
enclosing class by instantiating it.



An inner class is a non-static nested class.



The natural application for inner class is to declare
classes that are used only inside some other class or
that are closely related to another.



Inner classes may declare only compile time
constant fields.



inner and anonymous classes can make your Java
code easier to understand and maintain. They keep
related classes in the same source file and avoid the
proliferation of very small classes



Non-static inner classes have some limitations,
though. Specifically, they cannot declare static
initializers and static members, except in constant
fields. Besides that, inner classes declared inside
methods cannot access the method’s local variables
and parameters, unless they are declared final.



Inner-Anonymous classes are classes that don’t have
a name (hence the term anonymous). Because they
don’t have a name, there is no way to refer to them.
For this reason, their declaration must be given at
creation time, as part of the new statement.



Technically, anonymous classes are considered nonstatic inner classes, so they have the same privileges
and limitations of non-static inner classes declared
inside a method.

Lecture/core/oops3/10

Page #4

feel the Technology…

Weitere ähnliche Inhalte

Was ist angesagt?

WHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAWHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAsivasundari6
 
Understanding class, object & interface
Understanding class, object & interfaceUnderstanding class, object & interface
Understanding class, object & interfaceMD. Shohag Mia
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented PrinciplesSujit Majety
 
Inheritance, Object Oriented Programming
Inheritance, Object Oriented ProgrammingInheritance, Object Oriented Programming
Inheritance, Object Oriented ProgrammingArslan Waseem
 
Access modifiers
Access modifiersAccess modifiers
Access modifiersJadavsejal
 
What are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | EdurekaWhat are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | EdurekaEdureka!
 
Java - Inheritance Concepts
Java - Inheritance ConceptsJava - Inheritance Concepts
Java - Inheritance ConceptsVicter Paul
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...cprogrammings
 
Java interfaces
Java interfacesJava interfaces
Java interfacesjehan1987
 
abstract class and interface.Net
abstract class and interface.Netabstract class and interface.Net
abstract class and interface.NetBGSBU Rajouri
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Vineeta Garg
 
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...Simplilearn
 

Was ist angesagt? (20)

Friend function OOPC
Friend function OOPCFriend function OOPC
Friend function OOPC
 
WHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAWHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVA
 
Friend function in c++
Friend function in c++ Friend function in c++
Friend function in c++
 
Understanding class, object & interface
Understanding class, object & interfaceUnderstanding class, object & interface
Understanding class, object & interface
 
Java programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- InheritanceJava programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- Inheritance
 
Friend Function
Friend FunctionFriend Function
Friend Function
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented Principles
 
Inheritance, Object Oriented Programming
Inheritance, Object Oriented ProgrammingInheritance, Object Oriented Programming
Inheritance, Object Oriented Programming
 
Access modifiers
Access modifiersAccess modifiers
Access modifiers
 
What are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | EdurekaWhat are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | Edureka
 
Java - Inheritance Concepts
Java - Inheritance ConceptsJava - Inheritance Concepts
Java - Inheritance Concepts
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
 
Oop
OopOop
Oop
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
javainterface
javainterfacejavainterface
javainterface
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
abstract class and interface.Net
abstract class and interface.Netabstract class and interface.Net
abstract class and interface.Net
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
 

Andere mochten auch

纖維 Revision
纖維 Revision纖維 Revision
纖維 RevisionNg Lim
 
Matteo baccan raspberry pi - linox 2014
Matteo baccan   raspberry pi - linox 2014Matteo baccan   raspberry pi - linox 2014
Matteo baccan raspberry pi - linox 2014Matteo Baccan
 
设计资料总结
设计资料总结设计资料总结
设计资料总结yamingd
 
Cat And Mouse Story
Cat And Mouse StoryCat And Mouse Story
Cat And Mouse Storyguestd57ddf
 
yes we can
yes we canyes we can
yes we canyuu_2003
 
9thGradeBuildingPresentation
9thGradeBuildingPresentation9thGradeBuildingPresentation
9thGradeBuildingPresentationKent ISD
 
Presentatie Starterslift Breda - Online marketing
Presentatie Starterslift Breda - Online marketingPresentatie Starterslift Breda - Online marketing
Presentatie Starterslift Breda - Online marketingSjef Kerkhofs
 
Workshop digitaal branden
Workshop digitaal brandenWorkshop digitaal branden
Workshop digitaal brandenSjef Kerkhofs
 
Семинар по генным сетям. Mirob.
Семинар по генным сетям. Mirob.Семинар по генным сетям. Mirob.
Семинар по генным сетям. Mirob.bifurcafe
 
Newmedia Congres Webversie
Newmedia Congres WebversieNewmedia Congres Webversie
Newmedia Congres WebversieSjef Kerkhofs
 
Phpday 2009 php e java
Phpday 2009 php e javaPhpday 2009 php e java
Phpday 2009 php e javaMatteo Baccan
 

Andere mochten auch (20)

How... Do you know?
How... Do you know?How... Do you know?
How... Do you know?
 
纖維 Revision
纖維 Revision纖維 Revision
纖維 Revision
 
Matteo baccan raspberry pi - linox 2014
Matteo baccan   raspberry pi - linox 2014Matteo baccan   raspberry pi - linox 2014
Matteo baccan raspberry pi - linox 2014
 
设计资料总结
设计资料总结设计资料总结
设计资料总结
 
Guia de blogger
Guia de bloggerGuia de blogger
Guia de blogger
 
Passive voice
Passive voicePassive voice
Passive voice
 
Cat And Mouse Story
Cat And Mouse StoryCat And Mouse Story
Cat And Mouse Story
 
yes we can
yes we canyes we can
yes we can
 
9thGradeBuildingPresentation
9thGradeBuildingPresentation9thGradeBuildingPresentation
9thGradeBuildingPresentation
 
Presentatie Starterslift Breda - Online marketing
Presentatie Starterslift Breda - Online marketingPresentatie Starterslift Breda - Online marketing
Presentatie Starterslift Breda - Online marketing
 
Workshop digitaal branden
Workshop digitaal brandenWorkshop digitaal branden
Workshop digitaal branden
 
Семинар по генным сетям. Mirob.
Семинар по генным сетям. Mirob.Семинар по генным сетям. Mirob.
Семинар по генным сетям. Mirob.
 
Talking In Class
Talking In ClassTalking In Class
Talking In Class
 
Lecture25
Lecture25Lecture25
Lecture25
 
Presentatie ANWB
Presentatie  ANWBPresentatie  ANWB
Presentatie ANWB
 
Newmedia Congres Webversie
Newmedia Congres WebversieNewmedia Congres Webversie
Newmedia Congres Webversie
 
Niver Fe 18.02.07
Niver Fe 18.02.07Niver Fe 18.02.07
Niver Fe 18.02.07
 
Phpday 2009 php e java
Phpday 2009 php e javaPhpday 2009 php e java
Phpday 2009 php e java
 
Ethics And Values
Ethics And ValuesEthics And Values
Ethics And Values
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 

Ähnlich wie Lecture 10

Master of Computer Application (MCA) – Semester 4 MC0078
Master of Computer Application (MCA) – Semester 4  MC0078Master of Computer Application (MCA) – Semester 4  MC0078
Master of Computer Application (MCA) – Semester 4 MC0078Aravind NC
 
Java/J2EE interview Qestions
Java/J2EE interview QestionsJava/J2EE interview Qestions
Java/J2EE interview QestionsArun Vasanth
 
Object Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and InterfacesObject Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and InterfacesHabtamu Wolde
 
this keyword in Java.pdf
this keyword in Java.pdfthis keyword in Java.pdf
this keyword in Java.pdfParvizMirzayev2
 
Java abstract Keyword.pdf
Java abstract Keyword.pdfJava abstract Keyword.pdf
Java abstract Keyword.pdfSudhanshiBakre1
 
Basic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobBasic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobGaruda Trainings
 
Abstraction in java.pptx
Abstraction in java.pptxAbstraction in java.pptx
Abstraction in java.pptxAsifMulani17
 
Complete java&j2ee
Complete java&j2eeComplete java&j2ee
Complete java&j2eeShiva Cse
 
Top 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDETTop 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDETDevLabs Alliance
 
Dev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdetDev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdetdevlabsalliance
 
Abstraction in java [abstract classes and Interfaces
Abstraction in java [abstract classes and InterfacesAbstraction in java [abstract classes and Interfaces
Abstraction in java [abstract classes and InterfacesAhmed Nobi
 
9781439035665 ppt ch10
9781439035665 ppt ch109781439035665 ppt ch10
9781439035665 ppt ch10Terry Yoast
 
When to use abstract class and methods in java
When to use abstract class and methods in java When to use abstract class and methods in java
When to use abstract class and methods in java kritikumar16
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance pptNivegeetha
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview QuestionsKuntal Bhowmick
 

Ähnlich wie Lecture 10 (20)

Master of Computer Application (MCA) – Semester 4 MC0078
Master of Computer Application (MCA) – Semester 4  MC0078Master of Computer Application (MCA) – Semester 4  MC0078
Master of Computer Application (MCA) – Semester 4 MC0078
 
Java/J2EE interview Qestions
Java/J2EE interview QestionsJava/J2EE interview Qestions
Java/J2EE interview Qestions
 
Object Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and InterfacesObject Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and Interfaces
 
Chapter 9 java
Chapter 9 javaChapter 9 java
Chapter 9 java
 
this keyword in Java.pdf
this keyword in Java.pdfthis keyword in Java.pdf
this keyword in Java.pdf
 
Core java questions
Core java questionsCore java questions
Core java questions
 
Java Core
Java CoreJava Core
Java Core
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Java abstract Keyword.pdf
Java abstract Keyword.pdfJava abstract Keyword.pdf
Java abstract Keyword.pdf
 
Basic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobBasic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a job
 
Abstraction in java.pptx
Abstraction in java.pptxAbstraction in java.pptx
Abstraction in java.pptx
 
Complete java&j2ee
Complete java&j2eeComplete java&j2ee
Complete java&j2ee
 
Top 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDETTop 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDET
 
Dev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdetDev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdet
 
Abstraction in java [abstract classes and Interfaces
Abstraction in java [abstract classes and InterfacesAbstraction in java [abstract classes and Interfaces
Abstraction in java [abstract classes and Interfaces
 
Pocket java
Pocket javaPocket java
Pocket java
 
9781439035665 ppt ch10
9781439035665 ppt ch109781439035665 ppt ch10
9781439035665 ppt ch10
 
When to use abstract class and methods in java
When to use abstract class and methods in java When to use abstract class and methods in java
When to use abstract class and methods in java
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance ppt
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview Questions
 

Mehr von Debasish Pratihari (18)

Lecture 24
Lecture 24Lecture 24
Lecture 24
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
Lecture 21
Lecture 21Lecture 21
Lecture 21
 
Lecture 20
Lecture 20Lecture 20
Lecture 20
 
Lecture 19
Lecture 19Lecture 19
Lecture 19
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
 
Lecture 16
Lecture 16Lecture 16
Lecture 16
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 

Kürzlich hochgeladen

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Kürzlich hochgeladen (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Lecture 10

  • 1. Core Java Debasish Pratihari Inheritance :   Object oriented programming allows classes to inherit commonly used state and behavior from other class through inheritance. Allows a class to acquire the members of another class.  Parent-child/super-sub relationship is established.  Child can not restrict the scope of inheritance.  By default java classes are sub class of Object class directly or indirectly.  Java does not supports multiple inheritance. Parent/super decide the members that can be inherited by access specifiers.  Note:  Java uses a keyword extends to inherit.  Primarily solves two purposes. Re-usability and Providing a generic behavior.  A super class reference can refer to any object of its subclass.  If signature of a function in the super class is same as the signature of a function in the sub-class then the function is said to be over-ridden and it can’t be called by the object of sub class.  Any other class reference can be assigned to Object Class object.   If a function is declared as final it can’t be over-ridden. Incase of a child class member having the same name as of a parent class member then the parent class member is suppresses. And then to call those parent class members we have to use the super keyword.   If a class is final then it is restricted to be inherited. Compiler attaches a word super() as the first line of the constructor by default which calls the no-args constructor of the parent.  Note : Super object always holds address/reference of parent class. Lecture/core/oops3/10 Page #1 feel the Technology…
  • 2. Core Java Debasish Pratihari Abstract Class:  An abstract class is specifically designed to be inherited only. i.e. it can’t be instantiated. However it can be used to create object reference.  A class can be made Abstract by using the keyword “abstract”  If a class contains any abstract method then it must be declared as abstract.  A abstract class may have fully defined methods (concrete methods) also. Abstract Method:  Abstract methods are not concrete methods.  They need to be override by the subclasses.  An abstract method force to declare its class as abstract. Example : abstract class Shape{ abstract void getData(); void aboutUs(){ System.out.println(“Developed by Debasish at Lakshya”); } } class Circle extends Shape{ void getData(){ //method definition here } } Lecture/core/oops3/10 Page #2 feel the Technology…
  • 3. Core Java Debasish Pratihari Interface:  Using the keyword interface, you can fully abstract a class interface from its implementation.  Using interface, you can specify what a class must do, but not how it does it.  Interfaces are lack of instance variable, and their methods are declared without any body  A class can implement any number of interfaces  To implement an interface, a class must create a complete set of methods defined by the interface.  All the variables of an interface are public, static and final .All methods are abstract.  The methods of a class that implements can interface must be declared public.  It is both permissible and common for classes that implement interfaces to define additional members of their own.  You can declare variables as object reference that uses an interface rather than a class type. Any instance of any class that implements the declared interface can be referred to by such variable.  An interface reference variable only has knowledge of the methods declared by its interface declaration  If a class includes an interface but does not fully implement the methods defined by that interface, than that class must be declared as abstract  One interface can inherit another interface by use of the keyword extends.  When a class implements an interface that inherits another interface, it must provide implementation for all the methods defined within the interface inheritance chain. Lecture/core/oops3/10 Page #3 feel the Technology…
  • 4. Core Java Debasish Pratihari Nested, Inner and Anonymous Classes:  A class can be defined inside another class, called nested class.  Its scope is limited within its enclosing class.  A nested class can access all the members of its enclosing class including private members. But the enclosing class can’t access any member of the nested class.  The nested class can be static or non-static  A static nested class can access the members of its enclosing class by instantiating it.  An inner class is a non-static nested class.  The natural application for inner class is to declare classes that are used only inside some other class or that are closely related to another.  Inner classes may declare only compile time constant fields.  inner and anonymous classes can make your Java code easier to understand and maintain. They keep related classes in the same source file and avoid the proliferation of very small classes  Non-static inner classes have some limitations, though. Specifically, they cannot declare static initializers and static members, except in constant fields. Besides that, inner classes declared inside methods cannot access the method’s local variables and parameters, unless they are declared final.  Inner-Anonymous classes are classes that don’t have a name (hence the term anonymous). Because they don’t have a name, there is no way to refer to them. For this reason, their declaration must be given at creation time, as part of the new statement.  Technically, anonymous classes are considered nonstatic inner classes, so they have the same privileges and limitations of non-static inner classes declared inside a method. Lecture/core/oops3/10 Page #4 feel the Technology…