SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

Java Puzzle
Java PuzzleJava Puzzle
Java Puzzle
SFilipp
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)
Alok Kumar
 

Tendances (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)
 

En vedette (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
 

Similaire à 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.pdf
JayveeCultivo
 
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
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 preview
Paulo 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.pdf
ShashikantSathe3
 

Similaire à 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
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
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
vu2urc
 
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
Earley Information Science
 

Dernier (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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 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?
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 
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
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

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