SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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)
 

Destacado

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
 

Destacado (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 a 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 a 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
 

Último

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation 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
 
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
 
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
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
"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 ...Zilliz
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
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.pptxRustici Software
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 

Último (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation 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
 
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
 
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
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
"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 ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

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