SlideShare a Scribd company logo
1 of 49
JAVA
FUNDAMENTALS
Eng : Hatem Abd El-Salam
Lecture 5
Agenda
 Intro to OOP
 Classes
 Constructor
 Inheritance
 Final
 Static
 Inner classes
© 2016 by Eng. Hatem Abd El-Salam
OOP
What is OOP ?
 OOP is mapping the real world to software
 OOP is a community of integrating agents called Objects
 Each Object is perform an action that is used by other objects in the community.
 All Objects are instance of a class
© 2016 by Eng. Hatem Abd El-Salam
OOP
© 2016 by Eng. Hatem Abd El-Salam
OOP
© 2016 by Eng. Hatem Abd El-Salam
OOP
© 2016 by Eng. Hatem Abd El-Salam
OOP
© 2016 by Eng. Hatem Abd El-Salam
OOP
© 2016 by Eng. Hatem Abd El-Salam
Classes
© 2016 by Eng. Hatem Abd El-Salam
Classes (Cont.)
 Think of an appropriate name for your class
• Don’t use XYZ or ant random names
 Class Name start with CAPITAL letter
 No reserved words
 No numbers or special characters
 File.java must has at least one class
 If you create two classes at the same file one of them must be public
 File.java name = public class name
© 2016 by Eng. Hatem Abd El-Salam
Classes (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Classes (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Constructor
 Constructor in java is a special type of method that is used to initialize the object.
 Java constructor : is invoked at the time of object creation.
 It constructs the values i.e. provides data for the object that is why it is known as
constructor.
Rules for creating java constructor:
There are basically two rules defined for the constructor:
• Constructor name must be same as its class name
• Constructor must have no explicit return type
© 2016 by Eng. Hatem Abd El-Salam
Constructor (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Constructor (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Constructor (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Constructor (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Inheritance
© 2016 by Eng. Hatem Abd El-Salam
Inheritance (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Inheritance (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Inheritance (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Inheritance (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Inheritance (Cont.)
Types of inheritance in java
© 2016 by Eng. Hatem Abd El-Salam
Inheritance (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Inheritance (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Final
© 2016 by Eng. Hatem Abd El-Salam
Final (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Final (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Final (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Final (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Final (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Final (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Final (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Final (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Static
 The static keyword
in java is used for memory management mainly.
We can apply java static keyword with variables, methods, blocks and nested class.
The static keyword belongs to the class than instance of the class.
 The static can be:
 variable (also known as class variable)
 method (also known as class method)
 block
 nested class
© 2016 by Eng. Hatem Abd El-Salam
Static (Cont.)
 Java static variable
 If you declare any variable as static, it is known static variable.
 The static variable can be used to refer the common property of all objects (that is
not unique for each object)
 The static variable gets memory only once in class area at the time of class loading.
Advantage of static variable
 It makes your program memory efficient (it saves memory)
© 2016 by Eng. Hatem Abd El-Salam
Static (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Static (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Static (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Static (Cont.)
 Counter without static variable
© 2016 by Eng. Hatem Abd El-Salam
Static (Cont.)
 Counter by static variable
© 2016 by Eng. Hatem Abd El-Salam
Static (Cont.)
 If you apply static keyword with any method, it is known as static method.
 A static method belongs to the class rather than object of a class.
 A static method can be invoked without the need for creating an instance of a class.
 Static method can access static data member and can change the value of it.
© 2016 by Eng. Hatem Abd El-Salam
Static (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Static (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Inner classes
© 2016 by Eng. Hatem Abd El-Salam
Inner classes (Cont.)
© 2016 by Eng. Hatem Abd El-Salam
Inner classes (Cont.)
 Types of Nested classes
 There are two types of nested classes non-static and static nested classes.
The non-static nested classes are also known as inner classes.
 Non-static nested class (inner class)
a) Member inner class
b) Annomynous inner class
c) Local inner class
 Static nested class
© 2016 by Eng. Hatem Abd El-Salam
© 2016 by Eng. Hatem Abd El-Salam
Name : Eng. Hatem Abd El-Salam
Email : Hatemabdelsalam@Hotmail.com
LinkedIn : linkedin.com/in/hatemabdelsalam
SlideShare : slideshare.net/HatemAbdElSalam
Contact Details
© 2016 by Eng. Hatem Abd El-Salam

More Related Content

More from Hatem Abd El-Salam

More from Hatem Abd El-Salam (8)

C- language Lecture 8
C- language Lecture 8C- language Lecture 8
C- language Lecture 8
 
C- language Lecture 7
C- language Lecture 7C- language Lecture 7
C- language Lecture 7
 
C- language Lecture 6
C- language Lecture 6C- language Lecture 6
C- language Lecture 6
 
C- language Lecture 5
C- language Lecture 5C- language Lecture 5
C- language Lecture 5
 
C- language Lecture 4
C- language Lecture 4C- language Lecture 4
C- language Lecture 4
 
C- language Lecture 3
C- language Lecture 3C- language Lecture 3
C- language Lecture 3
 
C- Language Lecture 2
C- Language Lecture 2C- Language Lecture 2
C- Language Lecture 2
 
C-language Lecture 1
C-language Lecture 1C-language Lecture 1
C-language Lecture 1
 

Recently uploaded

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 

Recently uploaded (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 

Java- language Lecture 5