SlideShare une entreprise Scribd logo
1  sur  25
Introduction to Class

Object-Oriented Programming
Module Introduction

1.

Classes and Objects

2.

Instance variables

3.

Methods

FPT- APTECH

2/28
#1 – Classes and Objects



Class declaration



Constructors



Creating objects

FPT- APTECH

3/28
Creating Class



The template or blueprint from which
objects are actually made.



Syntax:
class ClassName{
//definition of class
}



All code that you write in Java is inside a
class.



Classes can be built by extending other
classes
FPT- APTECH

4/28
Constructor - how to instance an object?



Same name as the class.



A class can have more than one constructor.



A constructor can take zero, one, or more parameters.



Has no return value.



Always called with the new operator.



Use for initializing variables and invoking any methods that
may be for initialization.



If a class does not have an explicit constructor, a default
constructor (no-argument) is provided.
FPT- APTECH

5/28
Dissecting the Rectangle class
Name of class
1. Use Naming rules

Data member

2. Always captain first letter

• WhatConstructor
data does it need to
3. Use Noun for naming
know?
•

Define the way to
instance object

1. Same name as the
class name
Methods
2. Like function in C but
• Whathave no do? value
can it return
1. Like function in C
2. Use Verb for naming
3. Always lower first letter
FPT- APTECH

6/28
Creating objects (instance object)



An object must be created before using in a program.

1.

Declare a variable to store the object reference.
1.
Objects can only be manipulated via references

2.

Creating an object.
1.
Using the new operator in conjunction with a call to a constructor

FPT- APTECH

7/28
#2 – Data Member



Instance Variables



Class Variables

FPT- APTECH

8/28
Instance variables



The values of those variables
define the state of object.



All instances of a class have
the same instance variables
 May have different values
inside them.



Has an “access modifier”
associated with it.

FPT- APTECH

9/28
Example of Instance variables

recA
length = 3.0
width = 4.0

FPT- APTECH

recB
length = 6.4
width = 4.7

10/28
Class Variables (Static Variables)



Variable that is accessed
without using an object of a
class.



Declare using the static
keyword.



Only one copy of a static
variable is shared by all the
objects of the class.
 Change in the value of static
variable is reflected by all the
objects of the class.
FPT- APTECH

11/28
Example of Static Variables

FPT- APTECH

12/28
#3 - Methods



Definition



Instance Method



Calling method and Passing Arguments by Value.



Calling method and Passing Arguments by Reference.



Static Methods



Variable Argument Methods

FPT- APTECH

13/28
Method



A method is defined as the actual implementation of an operation
on an object.



Syntax:

access_specifier modifier datatype
method_name (parameter_list)
{
//body of the method
}


The method name should begin with
a lowercase verb and follow with
a proper noun.

FPT- APTECH

14/28
Instance Method



A function defined in a class



Invoked by an instance object
and can access instance
variables



Provide a mechanism for
accessing the private data
stored in an object

FPT- APTECH

15/28
Invoking Methods



Using the '.' operator



Syntax:
 <the object reference> ‘.’ <the method to be invoked>

FPT- APTECH

16/28
Calling method and Passing Arguments by Value.



Value from calling method is passed as an argument to the
called method.



Any change made to that passed value in the called method
will not modify the value in the calling method.



Variables of primitive types (int, float ..) are passed by value.

FPT- APTECH

17/28
Example of Calling method and Passing Arguments by
Value.

FPT- APTECH

18/28
Calling method and Passing Arguments by Reference.



Called method to change the value of the parameter passed
to if from the calling method.



When references are passed as parameters, the caller can
change the values stored but not the reference variables.

FPT- APTECH

19/28
Example of Calling method and Passing Arguments by
Reference

FPT- APTECH

20/28
Static Methods



Methods that do not operate on objects.
 Can be called without creating any objects of the class.



Call static method, supply the name of the class.



Declared using the static keyword.



Can directly refer only to static variables and other static
methods of the class.



Cannot refer to non-static methods and variables

FPT- APTECH

21/28
Example of Static Methods

FPT- APTECH

22/28
static methods usage



When a method doesn't need to access the object state



When a method only needs to access static fields of the
class.

FPT- APTECH

23/28
Variable Argument Methods



Allow calling a method with variable number of arguments.

FPT- APTECH

24/28
That’s about all for today!


Classes and Objects



Instance variables



Methods

Thank you all for your attention and patient !

Contenu connexe

Tendances

Tendances (20)

Lecture02 java
Lecture02 javaLecture02 java
Lecture02 java
 
Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2
 
Java interfaces
Java   interfacesJava   interfaces
Java interfaces
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Ppt chapter06
Ppt chapter06Ppt chapter06
Ppt chapter06
 
Generics
GenericsGenerics
Generics
 
Java Chapter 04 - Writing Classes: part 1
Java Chapter 04 - Writing Classes: part 1Java Chapter 04 - Writing Classes: part 1
Java Chapter 04 - Writing Classes: part 1
 
Legacy Coderetreat @Budapest 2013 02 16
Legacy Coderetreat @Budapest 2013 02 16Legacy Coderetreat @Budapest 2013 02 16
Legacy Coderetreat @Budapest 2013 02 16
 
Ppt chapter11
Ppt chapter11Ppt chapter11
Ppt chapter11
 
My c++
My c++My c++
My c++
 
14 interface
14  interface14  interface
14 interface
 
9781439035665 ppt ch07
9781439035665 ppt ch079781439035665 ppt ch07
9781439035665 ppt ch07
 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
 
Finite state system or finite automata
Finite state system or finite automataFinite state system or finite automata
Finite state system or finite automata
 
Comparable vs comparator
Comparable vs comparatorComparable vs comparator
Comparable vs comparator
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statements
 
Ppt chapter03
Ppt chapter03Ppt chapter03
Ppt chapter03
 
17515
1751517515
17515
 
Ppt chapter05
Ppt chapter05Ppt chapter05
Ppt chapter05
 

En vedette

Git - Boost Your DEV Team Speed and Productivity
Git - Boost Your DEV Team Speed and ProductivityGit - Boost Your DEV Team Speed and Productivity
Git - Boost Your DEV Team Speed and ProductivityKMS Technology
 
Exadata - Smart Scan Testing
Exadata - Smart Scan TestingExadata - Smart Scan Testing
Exadata - Smart Scan TestingMonowar Mukul
 
Edtc6341 63 esther_sauceda_practice_test5
Edtc6341 63 esther_sauceda_practice_test5Edtc6341 63 esther_sauceda_practice_test5
Edtc6341 63 esther_sauceda_practice_test5esauceda12
 
Upgrade database using cloud_control Provisioning
Upgrade database using cloud_control Provisioning Upgrade database using cloud_control Provisioning
Upgrade database using cloud_control Provisioning Monowar Mukul
 
SOA Fusion Middleware installation
SOA Fusion Middleware installationSOA Fusion Middleware installation
SOA Fusion Middleware installationMonowar Mukul
 
Moving 12c database from NON-ASM to ASM
Moving 12c database from NON-ASM to ASMMoving 12c database from NON-ASM to ASM
Moving 12c database from NON-ASM to ASMMonowar Mukul
 
Exadata I/O Resource Manager (Exadata IORM)
Exadata I/O Resource Manager (Exadata IORM)Exadata I/O Resource Manager (Exadata IORM)
Exadata I/O Resource Manager (Exadata IORM)Monowar Mukul
 
Oracle 12c far sync standby instance
Oracle 12c far sync standby instanceOracle 12c far sync standby instance
Oracle 12c far sync standby instanceMonowar Mukul
 
Oracle 12c RAC (Advanced installation - Flex ASM)
Oracle 12c RAC (Advanced installation - Flex ASM)Oracle 12c RAC (Advanced installation - Flex ASM)
Oracle 12c RAC (Advanced installation - Flex ASM)Monowar Mukul
 
12c database migration from ASM storage to NON-ASM storage
12c database migration from ASM storage to NON-ASM storage12c database migration from ASM storage to NON-ASM storage
12c database migration from ASM storage to NON-ASM storageMonowar Mukul
 
TimesTen in memory database Creation
TimesTen in memory database Creation TimesTen in memory database Creation
TimesTen in memory database Creation Monowar Mukul
 
12c Flex ASM: Moving to Flex ASM
12c Flex ASM: Moving to Flex ASM12c Flex ASM: Moving to Flex ASM
12c Flex ASM: Moving to Flex ASMMonowar Mukul
 
12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs
12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs
12c: Testing audit features for Data Pump (Export & Import) and RMAN jobsMonowar Mukul
 
Advanced installation 12c rac
Advanced installation 12c racAdvanced installation 12c rac
Advanced installation 12c racMonowar Mukul
 
Copyright Crash Course 1st revised ppt 6340.64 Sonia Aldape
Copyright Crash Course 1st revised ppt 6340.64 Sonia AldapeCopyright Crash Course 1st revised ppt 6340.64 Sonia Aldape
Copyright Crash Course 1st revised ppt 6340.64 Sonia Aldapesoniaaldape
 
Exadata - BULK DATA LOAD Testing on Database Machine
Exadata - BULK DATA LOAD Testing on Database Machine Exadata - BULK DATA LOAD Testing on Database Machine
Exadata - BULK DATA LOAD Testing on Database Machine Monowar Mukul
 
Migration Database from SQL SERVER 2012 to Oracle12c with Pluggable Database
Migration Database from SQL SERVER 2012 to Oracle12c with Pluggable Database  Migration Database from SQL SERVER 2012 to Oracle12c with Pluggable Database
Migration Database from SQL SERVER 2012 to Oracle12c with Pluggable Database Monowar Mukul
 
Oracle EM12c Edit or Create Incident rules and Setup SMS alert
Oracle EM12c Edit or Create Incident rules and Setup SMS alertOracle EM12c Edit or Create Incident rules and Setup SMS alert
Oracle EM12c Edit or Create Incident rules and Setup SMS alertMonowar Mukul
 

En vedette (20)

Git - Boost Your DEV Team Speed and Productivity
Git - Boost Your DEV Team Speed and ProductivityGit - Boost Your DEV Team Speed and Productivity
Git - Boost Your DEV Team Speed and Productivity
 
1247g3hg1238 2011
1247g3hg1238 20111247g3hg1238 2011
1247g3hg1238 2011
 
Exadata - Smart Scan Testing
Exadata - Smart Scan TestingExadata - Smart Scan Testing
Exadata - Smart Scan Testing
 
Edtc6341 63 esther_sauceda_practice_test5
Edtc6341 63 esther_sauceda_practice_test5Edtc6341 63 esther_sauceda_practice_test5
Edtc6341 63 esther_sauceda_practice_test5
 
Exadata Cell metrics
Exadata Cell metricsExadata Cell metrics
Exadata Cell metrics
 
Upgrade database using cloud_control Provisioning
Upgrade database using cloud_control Provisioning Upgrade database using cloud_control Provisioning
Upgrade database using cloud_control Provisioning
 
SOA Fusion Middleware installation
SOA Fusion Middleware installationSOA Fusion Middleware installation
SOA Fusion Middleware installation
 
Moving 12c database from NON-ASM to ASM
Moving 12c database from NON-ASM to ASMMoving 12c database from NON-ASM to ASM
Moving 12c database from NON-ASM to ASM
 
Exadata I/O Resource Manager (Exadata IORM)
Exadata I/O Resource Manager (Exadata IORM)Exadata I/O Resource Manager (Exadata IORM)
Exadata I/O Resource Manager (Exadata IORM)
 
Oracle 12c far sync standby instance
Oracle 12c far sync standby instanceOracle 12c far sync standby instance
Oracle 12c far sync standby instance
 
Oracle 12c RAC (Advanced installation - Flex ASM)
Oracle 12c RAC (Advanced installation - Flex ASM)Oracle 12c RAC (Advanced installation - Flex ASM)
Oracle 12c RAC (Advanced installation - Flex ASM)
 
12c database migration from ASM storage to NON-ASM storage
12c database migration from ASM storage to NON-ASM storage12c database migration from ASM storage to NON-ASM storage
12c database migration from ASM storage to NON-ASM storage
 
TimesTen in memory database Creation
TimesTen in memory database Creation TimesTen in memory database Creation
TimesTen in memory database Creation
 
12c Flex ASM: Moving to Flex ASM
12c Flex ASM: Moving to Flex ASM12c Flex ASM: Moving to Flex ASM
12c Flex ASM: Moving to Flex ASM
 
12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs
12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs
12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs
 
Advanced installation 12c rac
Advanced installation 12c racAdvanced installation 12c rac
Advanced installation 12c rac
 
Copyright Crash Course 1st revised ppt 6340.64 Sonia Aldape
Copyright Crash Course 1st revised ppt 6340.64 Sonia AldapeCopyright Crash Course 1st revised ppt 6340.64 Sonia Aldape
Copyright Crash Course 1st revised ppt 6340.64 Sonia Aldape
 
Exadata - BULK DATA LOAD Testing on Database Machine
Exadata - BULK DATA LOAD Testing on Database Machine Exadata - BULK DATA LOAD Testing on Database Machine
Exadata - BULK DATA LOAD Testing on Database Machine
 
Migration Database from SQL SERVER 2012 to Oracle12c with Pluggable Database
Migration Database from SQL SERVER 2012 to Oracle12c with Pluggable Database  Migration Database from SQL SERVER 2012 to Oracle12c with Pluggable Database
Migration Database from SQL SERVER 2012 to Oracle12c with Pluggable Database
 
Oracle EM12c Edit or Create Incident rules and Setup SMS alert
Oracle EM12c Edit or Create Incident rules and Setup SMS alertOracle EM12c Edit or Create Incident rules and Setup SMS alert
Oracle EM12c Edit or Create Incident rules and Setup SMS alert
 

Similaire à 4. java intro class

Chapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part IIChapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part IIEduardo Bergavera
 
Java As an OOP Language,Exception Handling & Applets
Java As an OOP Language,Exception Handling & AppletsJava As an OOP Language,Exception Handling & Applets
Java As an OOP Language,Exception Handling & AppletsHelen SagayaRaj
 
Java căn bản - Chapter7
Java căn bản - Chapter7Java căn bản - Chapter7
Java căn bản - Chapter7Vince Vo
 
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...vekariyakashyap
 
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesUNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesSakkaravarthiS1
 
9781439035665 ppt ch08
9781439035665 ppt ch089781439035665 ppt ch08
9781439035665 ppt ch08Terry Yoast
 
SOEN6441.generics.ppt
SOEN6441.generics.pptSOEN6441.generics.ppt
SOEN6441.generics.pptElieMambou1
 
Objectorientedprogrammingmodel1
Objectorientedprogrammingmodel1Objectorientedprogrammingmodel1
Objectorientedprogrammingmodel1bharath yelugula
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
 
chap 6 : Objects and classes (scjp/ocjp)
chap 6 : Objects and classes (scjp/ocjp)chap 6 : Objects and classes (scjp/ocjp)
chap 6 : Objects and classes (scjp/ocjp)It Academy
 
Effective Java - Design Method Signature Overload Varargs
Effective Java - Design Method Signature Overload VarargsEffective Java - Design Method Signature Overload Varargs
Effective Java - Design Method Signature Overload VarargsRoshan Deniyage
 
Learn Java language fundamentals with Unit nexus
Learn Java language fundamentals with Unit nexusLearn Java language fundamentals with Unit nexus
Learn Java language fundamentals with Unit nexusUnit Nexus Pvt. Ltd.
 

Similaire à 4. java intro class (20)

Hemajava
HemajavaHemajava
Hemajava
 
Java defining classes
Java defining classes Java defining classes
Java defining classes
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Chapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part IIChapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part II
 
Java As an OOP Language,Exception Handling & Applets
Java As an OOP Language,Exception Handling & AppletsJava As an OOP Language,Exception Handling & Applets
Java As an OOP Language,Exception Handling & Applets
 
Java căn bản - Chapter7
Java căn bản - Chapter7Java căn bản - Chapter7
Java căn bản - Chapter7
 
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
 
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesUNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
 
9781439035665 ppt ch08
9781439035665 ppt ch089781439035665 ppt ch08
9781439035665 ppt ch08
 
SOEN6441.generics.ppt
SOEN6441.generics.pptSOEN6441.generics.ppt
SOEN6441.generics.ppt
 
Objects and Types C#
Objects and Types C#Objects and Types C#
Objects and Types C#
 
Objectorientedprogrammingmodel1
Objectorientedprogrammingmodel1Objectorientedprogrammingmodel1
Objectorientedprogrammingmodel1
 
L5
L5L5
L5
 
Classes2
Classes2Classes2
Classes2
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
chap 6 : Objects and classes (scjp/ocjp)
chap 6 : Objects and classes (scjp/ocjp)chap 6 : Objects and classes (scjp/ocjp)
chap 6 : Objects and classes (scjp/ocjp)
 
Effective Java - Design Method Signature Overload Varargs
Effective Java - Design Method Signature Overload VarargsEffective Java - Design Method Signature Overload Varargs
Effective Java - Design Method Signature Overload Varargs
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
Learn Java language fundamentals with Unit nexus
Learn Java language fundamentals with Unit nexusLearn Java language fundamentals with Unit nexus
Learn Java language fundamentals with Unit nexus
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 

Dernier

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
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
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
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
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"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
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 

Dernier (20)

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
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
 
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
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
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
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"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
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"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...
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 

4. java intro class

  • 2. Module Introduction 1. Classes and Objects 2. Instance variables 3. Methods FPT- APTECH 2/28
  • 3. #1 – Classes and Objects  Class declaration  Constructors  Creating objects FPT- APTECH 3/28
  • 4. Creating Class  The template or blueprint from which objects are actually made.  Syntax: class ClassName{ //definition of class }  All code that you write in Java is inside a class.  Classes can be built by extending other classes FPT- APTECH 4/28
  • 5. Constructor - how to instance an object?  Same name as the class.  A class can have more than one constructor.  A constructor can take zero, one, or more parameters.  Has no return value.  Always called with the new operator.  Use for initializing variables and invoking any methods that may be for initialization.  If a class does not have an explicit constructor, a default constructor (no-argument) is provided. FPT- APTECH 5/28
  • 6. Dissecting the Rectangle class Name of class 1. Use Naming rules Data member 2. Always captain first letter • WhatConstructor data does it need to 3. Use Noun for naming know? • Define the way to instance object 1. Same name as the class name Methods 2. Like function in C but • Whathave no do? value can it return 1. Like function in C 2. Use Verb for naming 3. Always lower first letter FPT- APTECH 6/28
  • 7. Creating objects (instance object)  An object must be created before using in a program. 1. Declare a variable to store the object reference. 1. Objects can only be manipulated via references 2. Creating an object. 1. Using the new operator in conjunction with a call to a constructor FPT- APTECH 7/28
  • 8. #2 – Data Member  Instance Variables  Class Variables FPT- APTECH 8/28
  • 9. Instance variables  The values of those variables define the state of object.  All instances of a class have the same instance variables  May have different values inside them.  Has an “access modifier” associated with it. FPT- APTECH 9/28
  • 10. Example of Instance variables recA length = 3.0 width = 4.0 FPT- APTECH recB length = 6.4 width = 4.7 10/28
  • 11. Class Variables (Static Variables)  Variable that is accessed without using an object of a class.  Declare using the static keyword.  Only one copy of a static variable is shared by all the objects of the class.  Change in the value of static variable is reflected by all the objects of the class. FPT- APTECH 11/28
  • 12. Example of Static Variables FPT- APTECH 12/28
  • 13. #3 - Methods  Definition  Instance Method  Calling method and Passing Arguments by Value.  Calling method and Passing Arguments by Reference.  Static Methods  Variable Argument Methods FPT- APTECH 13/28
  • 14. Method  A method is defined as the actual implementation of an operation on an object.  Syntax: access_specifier modifier datatype method_name (parameter_list) { //body of the method }  The method name should begin with a lowercase verb and follow with a proper noun. FPT- APTECH 14/28
  • 15. Instance Method  A function defined in a class  Invoked by an instance object and can access instance variables  Provide a mechanism for accessing the private data stored in an object FPT- APTECH 15/28
  • 16. Invoking Methods  Using the '.' operator  Syntax:  <the object reference> ‘.’ <the method to be invoked> FPT- APTECH 16/28
  • 17. Calling method and Passing Arguments by Value.  Value from calling method is passed as an argument to the called method.  Any change made to that passed value in the called method will not modify the value in the calling method.  Variables of primitive types (int, float ..) are passed by value. FPT- APTECH 17/28
  • 18. Example of Calling method and Passing Arguments by Value. FPT- APTECH 18/28
  • 19. Calling method and Passing Arguments by Reference.  Called method to change the value of the parameter passed to if from the calling method.  When references are passed as parameters, the caller can change the values stored but not the reference variables. FPT- APTECH 19/28
  • 20. Example of Calling method and Passing Arguments by Reference FPT- APTECH 20/28
  • 21. Static Methods  Methods that do not operate on objects.  Can be called without creating any objects of the class.  Call static method, supply the name of the class.  Declared using the static keyword.  Can directly refer only to static variables and other static methods of the class.  Cannot refer to non-static methods and variables FPT- APTECH 21/28
  • 22. Example of Static Methods FPT- APTECH 22/28
  • 23. static methods usage  When a method doesn't need to access the object state  When a method only needs to access static fields of the class. FPT- APTECH 23/28
  • 24. Variable Argument Methods  Allow calling a method with variable number of arguments. FPT- APTECH 24/28
  • 25. That’s about all for today!  Classes and Objects  Instance variables  Methods Thank you all for your attention and patient !