SlideShare a Scribd company logo
1 of 29
Object oriented programming
(first )
By Eng.abed albaset hamam
Introduction
• general depiction of a java class using a
programming environment such as eclipse :
• //Package
• //import directives
• Access-Modifiers class className{
• // variables
• // Method ( functions) definitions
• }
Simple example
public class tom {
public static void main(String[] args) {
System.out.println("simple");
}}
• Why static ? static is keyword indicating the
method is static which means it has static address
which must determined at compile time
Questions for the previous example
• What main mean ? keyword which means an
address where the application or program will
start executing
What the output ??
System.out.println("abt"hello"");
The output abd "hello"
What the output ??
public class Mainx {
public static void main(String[] args) {
int x=3;
int y=4;
System.out.println(x+y);
}
}
Output 7
functions
• public class MyClass{
• public static void main(String[] args) {
• funA(); // direct function call statement
• System.out.print("bye");
• }
• static void funA(){
• //function body begin
• System.out.print("No value to return");
• }//function body ends
• }
Q for previous ex
• Questions :
• 1- What is the function name?
• 2- What is the function header?
• 4- Why the function does not have a return
statement?
• Answers :
• 1- FunA
• 2- Static void funA()
• 4- Because the function return data type field is
void, therefore it return
Overloading
• public class Mainx {
• public static void main(String[] args) {
• System.out.print(Fun(2.00));
• }
• static int fun(int x){
• return 1;
• }
• static int fun(double x){
• return 1;
• }
• static int fun(int x, int y){
• return 1;
• }
• }
Visibility
• public class tom {
• public static void main(String[] args) {
• {
• char c='a';
• }
• System.out.println(c);//error c not visible
• }
• }
• In can see the out but out cant see the in
visiblity
• static int Fun(int x){
• int z=1;
• {
• int x=4;// Naming collision error, x is already
declared
• }
• return 0;
• }
Recursive functions
• Example 10: Finding the factorial of an integer by using recursive function
calls
• public class Mainx {
• public static void main(String[] args) {
• int z=4;
• System.out.println(factorial(z));
• }
• static int factorial(int x){
• if(x==0)
• return 1;
• else
• return x*factorial(x-1);
• }
• }
Arrays
• One dimensional array
• public class Mainx {
• public static void main(String[] args) {
• int a[]={1,2,3};
• for(int i=0;i<3;i++){
• System.out.print(a[i]);
• }
• }
• }
Arrays
• Two dimensional arrays
• int a[][]={{1,2}, {3,4}};
• for(int i=0;i<2;i++){
• for(int j=0;j<2;j++){
• System.out.print(a[i][j]);
• }
• System.out.print("n");
• }
Find the error
• public class MyClass {
• public static void main(String[] args) {
• int x=5;
• {
• int x=6;
• }
• System.out.println(x);
• }
• }
Find the error
• public class MyClass {
• public static void main(String[] args) {
• int x=fun();
• }
• public int fun(){
• System.out.println("hello");
• return 1;
• }
• }
Find the error
• public class MyClass {
• public static void main(String[] args) {
• int x=1;
• if(x>=1){
• int y=3;
• }
• System.out.println(x+y);
• }
• }
Find the error
• public class MyClass {
• public static void main(String[] args) {
• fun(3);
• }
• static void fun(int z){
• int z=3;
• }
• }
What the output
• public class MyClass {
• public static void main(String[] args) {
• int a[]={1,2,3};
• System.out.println(fun(a));
• }
• public static int fun(int a[]){
• int sum=0;
• for(int i=0;i<3;i++){
• sum+=a[i];
• }
• return sum;
• }
• }
What the output
• public class tom {
• public static int fun(int x){
• return ++x;
• }
• public static void main(String[] args) {
• int z=4;
• z=fun(fun(fun(z)));
• System.out.println(z);
• }
• }
Find the error
• public class tom {
• public static int fun(int x){
• return x;
• }
• public static void main(String[] args) {
• double z=4;
• z=fun(fun(fun(z)));
• System.out.println(z);
• }
• }
Class variable
• public class tom {
• static int z=2;
• public static void fun2(){
• System.out.println(++z);
• }
• public static void fun3(){
• System.out.println(++z);
• }
• public static void main(String[] args) {
• fun3(); fun2();
• }
• }
What the output
• public class tom {
• static int z=8;
• public static void fun2(){
• System.out.println(++z);
• }
• public static void fun3(){
• System.out.println(++z);
• }
• public static void main(String[] args) {
• fun3(); fun2();fun3(); fun2();
• }
• }
What the output
• public class MyClass {
• static int z=5;
• public static void fun1(int x){
• int z=4,y=5;
System.out.println(x+y+z);
• }
• public static void fun2(int k){
• int x=1, y=2;
• System.out.println(x+y+k+z);
• }
• public static void main(String[] args) { fun1(1);fun2(2); } }
Defined the object
• MyClass objref = new MyClass(value);
constructur
Example on objects
What the output
What the error
this

More Related Content

What's hot

Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)Chhom Karath
 
Fourier project presentation
Fourier project  presentationFourier project  presentation
Fourier project presentation志璿 楊
 
JDays 2016 - Beyond Lambdas - the Aftermath
JDays 2016 - Beyond Lambdas - the AftermathJDays 2016 - Beyond Lambdas - the Aftermath
JDays 2016 - Beyond Lambdas - the AftermathDaniel Sawano
 
Spotify 2016 - Beyond Lambdas - the Aftermath
Spotify 2016 - Beyond Lambdas - the AftermathSpotify 2016 - Beyond Lambdas - the Aftermath
Spotify 2016 - Beyond Lambdas - the AftermathDaniel Sawano
 
Chap2 class,objects contd
Chap2 class,objects contdChap2 class,objects contd
Chap2 class,objects contdraksharao
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)mehul patel
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxEleanor McHugh
 
Java Puzzle
Java PuzzleJava Puzzle
Java PuzzleSFilipp
 
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...tdc-globalcode
 
Java Generics for Dummies
Java Generics for DummiesJava Generics for Dummies
Java Generics for Dummiesknutmork
 
Java Foundations: Maps, Lambda and Stream API
Java Foundations: Maps, Lambda and Stream APIJava Foundations: Maps, Lambda and Stream API
Java Foundations: Maps, Lambda and Stream APISvetlin Nakov
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlinintelliyole
 
The Ring programming language version 1.5.4 book - Part 33 of 185
The Ring programming language version 1.5.4 book - Part 33 of 185The Ring programming language version 1.5.4 book - Part 33 of 185
The Ring programming language version 1.5.4 book - Part 33 of 185Mahmoud Samir Fayed
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)Alok Kumar
 

What's hot (20)

Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
Fourier project presentation
Fourier project  presentationFourier project  presentation
Fourier project presentation
 
JDays 2016 - Beyond Lambdas - the Aftermath
JDays 2016 - Beyond Lambdas - the AftermathJDays 2016 - Beyond Lambdas - the Aftermath
JDays 2016 - Beyond Lambdas - the Aftermath
 
Spotify 2016 - Beyond Lambdas - the Aftermath
Spotify 2016 - Beyond Lambdas - the AftermathSpotify 2016 - Beyond Lambdas - the Aftermath
Spotify 2016 - Beyond Lambdas - the Aftermath
 
Chap2 class,objects contd
Chap2 class,objects contdChap2 class,objects contd
Chap2 class,objects contd
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
 
Java Puzzle
Java PuzzleJava Puzzle
Java Puzzle
 
Java puzzles
Java puzzlesJava puzzles
Java puzzles
 
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
 
Java Unit 1 Project
Java Unit 1 ProjectJava Unit 1 Project
Java Unit 1 Project
 
Java Generics for Dummies
Java Generics for DummiesJava Generics for Dummies
Java Generics for Dummies
 
Java Foundations: Maps, Lambda and Stream API
Java Foundations: Maps, Lambda and Stream APIJava Foundations: Maps, Lambda and Stream API
Java Foundations: Maps, Lambda and Stream API
 
Collection Core Concept
Collection Core ConceptCollection Core Concept
Collection Core Concept
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlin
 
The Ring programming language version 1.5.4 book - Part 33 of 185
The Ring programming language version 1.5.4 book - Part 33 of 185The Ring programming language version 1.5.4 book - Part 33 of 185
The Ring programming language version 1.5.4 book - Part 33 of 185
 
Java Puzzlers
Java PuzzlersJava Puzzlers
Java Puzzlers
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)
 

Viewers also liked

Reconeixer les monedes deuro
Reconeixer les monedes deuroReconeixer les monedes deuro
Reconeixer les monedes deuroHelena Enseñat
 
CV - Lazar_Gavric.PDF
CV - Lazar_Gavric.PDFCV - Lazar_Gavric.PDF
CV - Lazar_Gavric.PDFLazar Gavric
 
Ecological problems in estonia
Ecological problems in estoniaEcological problems in estonia
Ecological problems in estoniaTimo Priinits
 
Weather and activities
Weather and activitiesWeather and activities
Weather and activitiesJulia Giroldi
 
Rules for classrooms
Rules for classroomsRules for classrooms
Rules for classroomsJulia Giroldi
 
Engl 102 final exam 1
Engl 102 final exam 1Engl 102 final exam 1
Engl 102 final exam 1scorpions1232
 
Engl 102 final exam 3
Engl 102 final exam 3Engl 102 final exam 3
Engl 102 final exam 3scorpions1232
 
How to avoid to get sick.
How to avoid to get sick.How to avoid to get sick.
How to avoid to get sick.Julia Giroldi
 
Uts pak soko
Uts pak sokoUts pak soko
Uts pak sokoemon_19
 
Motivational quotes discussion 2
Motivational quotes discussion 2Motivational quotes discussion 2
Motivational quotes discussion 2prncss042304
 
Your face _farsi_
Your face _farsi_Your face _farsi_
Your face _farsi_Fibamicro1
 
PRO INDUSTRY LTD. - portfolio
PRO INDUSTRY LTD. - portfolioPRO INDUSTRY LTD. - portfolio
PRO INDUSTRY LTD. - portfolioLazar Gavric
 

Viewers also liked (16)

Reconeixer les monedes deuro
Reconeixer les monedes deuroReconeixer les monedes deuro
Reconeixer les monedes deuro
 
Morning routines
Morning routinesMorning routines
Morning routines
 
CV - Lazar_Gavric.PDF
CV - Lazar_Gavric.PDFCV - Lazar_Gavric.PDF
CV - Lazar_Gavric.PDF
 
Types of family
Types of familyTypes of family
Types of family
 
Global Warming
Global WarmingGlobal Warming
Global Warming
 
Ecological problems in estonia
Ecological problems in estoniaEcological problems in estonia
Ecological problems in estonia
 
Weather and activities
Weather and activitiesWeather and activities
Weather and activities
 
Delivery at Hooroo
Delivery at HoorooDelivery at Hooroo
Delivery at Hooroo
 
Rules for classrooms
Rules for classroomsRules for classrooms
Rules for classrooms
 
Engl 102 final exam 1
Engl 102 final exam 1Engl 102 final exam 1
Engl 102 final exam 1
 
Engl 102 final exam 3
Engl 102 final exam 3Engl 102 final exam 3
Engl 102 final exam 3
 
How to avoid to get sick.
How to avoid to get sick.How to avoid to get sick.
How to avoid to get sick.
 
Uts pak soko
Uts pak sokoUts pak soko
Uts pak soko
 
Motivational quotes discussion 2
Motivational quotes discussion 2Motivational quotes discussion 2
Motivational quotes discussion 2
 
Your face _farsi_
Your face _farsi_Your face _farsi_
Your face _farsi_
 
PRO INDUSTRY LTD. - portfolio
PRO INDUSTRY LTD. - portfolioPRO INDUSTRY LTD. - portfolio
PRO INDUSTRY LTD. - portfolio
 

Similar to Object oriented programming (first)

Java_Programming_by_Example_6th_Edition.pdf
Java_Programming_by_Example_6th_Edition.pdfJava_Programming_by_Example_6th_Edition.pdf
Java_Programming_by_Example_6th_Edition.pdfJayveeCultivo
 
Paradigma FP y OOP usando técnicas avanzadas de Programación | Programacion A...
Paradigma FP y OOP usando técnicas avanzadas de Programación | Programacion A...Paradigma FP y OOP usando técnicas avanzadas de Programación | Programacion A...
Paradigma FP y OOP usando técnicas avanzadas de Programación | Programacion A...Víctor Bolinches
 
Presentation1 computer shaan
Presentation1 computer shaanPresentation1 computer shaan
Presentation1 computer shaanwalia Shaan
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...MaruMengesha
 
Basic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIBasic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIjagriti srivastava
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewPaulo Morgado
 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfShashikantSathe3
 
Java Programs
Java ProgramsJava Programs
Java Programsvvpadhu
 
Basic program in java
Basic program in java Basic program in java
Basic program in java Sudeep Singh
 
Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010Qiangning Hong
 

Similar to Object oriented programming (first) (20)

Lab 3
Lab 3Lab 3
Lab 3
 
Java_Programming_by_Example_6th_Edition.pdf
Java_Programming_by_Example_6th_Edition.pdfJava_Programming_by_Example_6th_Edition.pdf
Java_Programming_by_Example_6th_Edition.pdf
 
Topic 3
Topic 3Topic 3
Topic 3
 
Paradigma FP y OOP usando técnicas avanzadas de Programación | Programacion A...
Paradigma FP y OOP usando técnicas avanzadas de Programación | Programacion A...Paradigma FP y OOP usando técnicas avanzadas de Programación | Programacion A...
Paradigma FP y OOP usando técnicas avanzadas de Programación | Programacion A...
 
Java introduction
Java introductionJava introduction
Java introduction
 
Presentation1 computer shaan
Presentation1 computer shaanPresentation1 computer shaan
Presentation1 computer shaan
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
 
Basic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIBasic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time API
 
Introduccion del curso
Introduccion del cursoIntroduccion del curso
Introduccion del curso
 
Parameters
ParametersParameters
Parameters
 
Java Program
Java ProgramJava Program
Java Program
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 preview
 
final year project center in Coimbatore
final year project center in Coimbatorefinal year project center in Coimbatore
final year project center in Coimbatore
 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
 
Closer look at classes
Closer look at classesCloser look at classes
Closer look at classes
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
Java 5 and 6 New Features
Java 5 and 6 New FeaturesJava 5 and 6 New Features
Java 5 and 6 New Features
 
Basic program in java
Basic program in java Basic program in java
Basic program in java
 
Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010
 
Comp102 lec 7
Comp102   lec 7Comp102   lec 7
Comp102 lec 7
 

Recently uploaded

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Recently uploaded (20)

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

Object oriented programming (first)

  • 1. Object oriented programming (first ) By Eng.abed albaset hamam
  • 2. Introduction • general depiction of a java class using a programming environment such as eclipse : • //Package • //import directives • Access-Modifiers class className{ • // variables • // Method ( functions) definitions • }
  • 3. Simple example public class tom { public static void main(String[] args) { System.out.println("simple"); }} • Why static ? static is keyword indicating the method is static which means it has static address which must determined at compile time
  • 4. Questions for the previous example • What main mean ? keyword which means an address where the application or program will start executing What the output ?? System.out.println("abt"hello""); The output abd "hello"
  • 5. What the output ?? public class Mainx { public static void main(String[] args) { int x=3; int y=4; System.out.println(x+y); } } Output 7
  • 6. functions • public class MyClass{ • public static void main(String[] args) { • funA(); // direct function call statement • System.out.print("bye"); • } • static void funA(){ • //function body begin • System.out.print("No value to return"); • }//function body ends • }
  • 7. Q for previous ex • Questions : • 1- What is the function name? • 2- What is the function header? • 4- Why the function does not have a return statement? • Answers : • 1- FunA • 2- Static void funA() • 4- Because the function return data type field is void, therefore it return
  • 8. Overloading • public class Mainx { • public static void main(String[] args) { • System.out.print(Fun(2.00)); • } • static int fun(int x){ • return 1; • } • static int fun(double x){ • return 1; • } • static int fun(int x, int y){ • return 1; • } • }
  • 9. Visibility • public class tom { • public static void main(String[] args) { • { • char c='a'; • } • System.out.println(c);//error c not visible • } • } • In can see the out but out cant see the in
  • 10. visiblity • static int Fun(int x){ • int z=1; • { • int x=4;// Naming collision error, x is already declared • } • return 0; • }
  • 11. Recursive functions • Example 10: Finding the factorial of an integer by using recursive function calls • public class Mainx { • public static void main(String[] args) { • int z=4; • System.out.println(factorial(z)); • } • static int factorial(int x){ • if(x==0) • return 1; • else • return x*factorial(x-1); • } • }
  • 12. Arrays • One dimensional array • public class Mainx { • public static void main(String[] args) { • int a[]={1,2,3}; • for(int i=0;i<3;i++){ • System.out.print(a[i]); • } • } • }
  • 13. Arrays • Two dimensional arrays • int a[][]={{1,2}, {3,4}}; • for(int i=0;i<2;i++){ • for(int j=0;j<2;j++){ • System.out.print(a[i][j]); • } • System.out.print("n"); • }
  • 14. Find the error • public class MyClass { • public static void main(String[] args) { • int x=5; • { • int x=6; • } • System.out.println(x); • } • }
  • 15. Find the error • public class MyClass { • public static void main(String[] args) { • int x=fun(); • } • public int fun(){ • System.out.println("hello"); • return 1; • } • }
  • 16. Find the error • public class MyClass { • public static void main(String[] args) { • int x=1; • if(x>=1){ • int y=3; • } • System.out.println(x+y); • } • }
  • 17. Find the error • public class MyClass { • public static void main(String[] args) { • fun(3); • } • static void fun(int z){ • int z=3; • } • }
  • 18. What the output • public class MyClass { • public static void main(String[] args) { • int a[]={1,2,3}; • System.out.println(fun(a)); • } • public static int fun(int a[]){ • int sum=0; • for(int i=0;i<3;i++){ • sum+=a[i]; • } • return sum; • } • }
  • 19. What the output • public class tom { • public static int fun(int x){ • return ++x; • } • public static void main(String[] args) { • int z=4; • z=fun(fun(fun(z))); • System.out.println(z); • } • }
  • 20. Find the error • public class tom { • public static int fun(int x){ • return x; • } • public static void main(String[] args) { • double z=4; • z=fun(fun(fun(z))); • System.out.println(z); • } • }
  • 21. Class variable • public class tom { • static int z=2; • public static void fun2(){ • System.out.println(++z); • } • public static void fun3(){ • System.out.println(++z); • } • public static void main(String[] args) { • fun3(); fun2(); • } • }
  • 22. What the output • public class tom { • static int z=8; • public static void fun2(){ • System.out.println(++z); • } • public static void fun3(){ • System.out.println(++z); • } • public static void main(String[] args) { • fun3(); fun2();fun3(); fun2(); • } • }
  • 23. What the output • public class MyClass { • static int z=5; • public static void fun1(int x){ • int z=4,y=5; System.out.println(x+y+z); • } • public static void fun2(int k){ • int x=1, y=2; • System.out.println(x+y+k+z); • } • public static void main(String[] args) { fun1(1);fun2(2); } }
  • 24. Defined the object • MyClass objref = new MyClass(value);
  • 29. this