SlideShare a Scribd company logo
Material 5
What is a class?
• Early languages had only arrays
– all elements had to be of the same type
• Then languages introduced structures (called
records, or structs)
– allowed different data types to be grouped
• Then Abstract Data Types (ADTs) became
popular
– grouped operations along with the data
So, what is a class?
• A class consists of
– a collection of fields, or variables, very much
like the named fields of a struct
– all the operations (called methods) that can be
performed on those fields
– can be instantiated
• A class describes objects and operations
defined on those objects
Name conventions
• Java is case-sensitive; maxval, maxVal, and
MaxVal are three different names
• Class names begin with a capital letter
• All other names begin with a lowercase letter
• Subsequent words are capitalized: theBigOne
• Underscores are not used in names
• These are very strong conventions!
The class hierarchy
• Classes are arranged in a hierarchy
• The root, or topmost, class is Object
• Every class but Object has at least one
superclass
• A class may have subclasses
• Each class inherits all the fields and methods
of its (possibly numerous) superclasses
An example of a class
class Person {
String name;
int age;
void birthday ( ) {
age++;
System.out.println (name + ' is now ' + age);
}
}
Another example of a class
class Driver extends Person {
long driversLicenseNumber;
Date expirationDate;
}

More Related Content

What's hot

Understanding Taxonomy, Drupal Camp Colorado, June 2009
Understanding Taxonomy, Drupal Camp Colorado, June 2009Understanding Taxonomy, Drupal Camp Colorado, June 2009
Understanding Taxonomy, Drupal Camp Colorado, June 2009
David Lanier
 
Infromation Reprentation, Structured Data and Semantics
Infromation Reprentation,Structured Data and SemanticsInfromation Reprentation,Structured Data and Semantics
Infromation Reprentation, Structured Data and Semantics
Yogendra Tamang
 
sw owl
 sw owl sw owl
Using DAS software, an introduction to some DAS implementations
Using DAS software, an introduction to some DAS implementationsUsing DAS software, an introduction to some DAS implementations
Using DAS software, an introduction to some DAS implementations
Rafael C. Jimenez
 
[圣思园][Java SE]Inner class
[圣思园][Java SE]Inner class[圣思园][Java SE]Inner class
[圣思园][Java SE]Inner class
ArBing Xie
 
Inner classes ,annoumous and outer classes in java
Inner classes ,annoumous and outer classes in javaInner classes ,annoumous and outer classes in java
Inner classes ,annoumous and outer classes in java
Adil Mehmoood
 
The named entity recognition (ner)2
The named entity recognition (ner)2The named entity recognition (ner)2
The named entity recognition (ner)2
Arabic_NLP_ImamU2013
 
LIS 653, Session 3: Principles and Standards
LIS 653, Session 3: Principles and Standards LIS 653, Session 3: Principles and Standards
LIS 653, Session 3: Principles and Standards
Dr. Starr Hoffman
 
Notation 3(n3)
Notation 3(n3)Notation 3(n3)
Notation 3(n3)
Yogendra Tamang
 
WordPress Development - Taxonomies
WordPress Development -  TaxonomiesWordPress Development -  Taxonomies
WordPress Development - Taxonomies
Juan Pablo De la torre Valdez
 
Understanding Metaclasses
Understanding MetaclassesUnderstanding Metaclasses
Understanding Metaclasses
Daniel Neuhäuser
 
Nested classes in java
Nested classes in javaNested classes in java
Nested classes in java
Richa Singh
 

What's hot (12)

Understanding Taxonomy, Drupal Camp Colorado, June 2009
Understanding Taxonomy, Drupal Camp Colorado, June 2009Understanding Taxonomy, Drupal Camp Colorado, June 2009
Understanding Taxonomy, Drupal Camp Colorado, June 2009
 
Infromation Reprentation, Structured Data and Semantics
Infromation Reprentation,Structured Data and SemanticsInfromation Reprentation,Structured Data and Semantics
Infromation Reprentation, Structured Data and Semantics
 
sw owl
 sw owl sw owl
sw owl
 
Using DAS software, an introduction to some DAS implementations
Using DAS software, an introduction to some DAS implementationsUsing DAS software, an introduction to some DAS implementations
Using DAS software, an introduction to some DAS implementations
 
[圣思园][Java SE]Inner class
[圣思园][Java SE]Inner class[圣思园][Java SE]Inner class
[圣思园][Java SE]Inner class
 
Inner classes ,annoumous and outer classes in java
Inner classes ,annoumous and outer classes in javaInner classes ,annoumous and outer classes in java
Inner classes ,annoumous and outer classes in java
 
The named entity recognition (ner)2
The named entity recognition (ner)2The named entity recognition (ner)2
The named entity recognition (ner)2
 
LIS 653, Session 3: Principles and Standards
LIS 653, Session 3: Principles and Standards LIS 653, Session 3: Principles and Standards
LIS 653, Session 3: Principles and Standards
 
Notation 3(n3)
Notation 3(n3)Notation 3(n3)
Notation 3(n3)
 
WordPress Development - Taxonomies
WordPress Development -  TaxonomiesWordPress Development -  Taxonomies
WordPress Development - Taxonomies
 
Understanding Metaclasses
Understanding MetaclassesUnderstanding Metaclasses
Understanding Metaclasses
 
Nested classes in java
Nested classes in javaNested classes in java
Nested classes in java
 

Viewers also liked

Lo15
Lo15Lo15
Lo15
liankei
 
Lo4
Lo4Lo4
Lo4
liankei
 
Lo19
Lo19Lo19
Lo19
liankei
 
01
0101
Lo20
Lo20Lo20
Lo20
liankei
 
Lo10
Lo10Lo10
Lo10
liankei
 
08
0808
Lo12
Lo12Lo12
Lo12
liankei
 
Lo11
Lo11Lo11
Lo11
liankei
 
Lo13
Lo13Lo13
Lo13
liankei
 
Lo2
Lo2Lo2
Lo2
liankei
 
Lo8
Lo8Lo8
Lo8
liankei
 
Lo18
Lo18Lo18
Lo18
liankei
 
02
0202
Lo9
Lo9Lo9
Lo9
liankei
 
Lo17
Lo17Lo17
Lo17
liankei
 
Lo14
Lo14Lo14
Lo14
liankei
 
Lo7
Lo7Lo7
Lo7
liankei
 
Lo16
Lo16Lo16
Lo16
liankei
 

Viewers also liked (19)

Lo15
Lo15Lo15
Lo15
 
Lo4
Lo4Lo4
Lo4
 
Lo19
Lo19Lo19
Lo19
 
01
0101
01
 
Lo20
Lo20Lo20
Lo20
 
Lo10
Lo10Lo10
Lo10
 
08
0808
08
 
Lo12
Lo12Lo12
Lo12
 
Lo11
Lo11Lo11
Lo11
 
Lo13
Lo13Lo13
Lo13
 
Lo2
Lo2Lo2
Lo2
 
Lo8
Lo8Lo8
Lo8
 
Lo18
Lo18Lo18
Lo18
 
02
0202
02
 
Lo9
Lo9Lo9
Lo9
 
Lo17
Lo17Lo17
Lo17
 
Lo14
Lo14Lo14
Lo14
 
Lo7
Lo7Lo7
Lo7
 
Lo16
Lo16Lo16
Lo16
 

Similar to Lo5

Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentals
AnsgarMary
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in java
Atul Sehdev
 
Concepts of oop1
Concepts of oop1Concepts of oop1
Concepts of oop1
SheetalPareek
 
Java chapter 5
Java chapter 5Java chapter 5
Java chapter 5
Abdii Rashid
 
RIBBUN SOFTWARE
RIBBUN SOFTWARERIBBUN SOFTWARE
RIBBUN SOFTWARE
mosewoodward24
 
Java01
Java01Java01
Java01
Java01Java01
Java01
Prakash Mani
 
Introduction what is java
Introduction what is javaIntroduction what is java
Introduction what is java
sanjeeviniindia1186
 
Java01
Java01Java01
Java01
Java01Java01
Dewey Classification
Dewey ClassificationDewey Classification
Dewey Classification
Denise Garofalo
 
Introducing classes
Introducing classesIntroducing classes
Introducing classes
Riaz Ahmed
 
BT02.pptx
BT02.pptxBT02.pptx
BT02.pptx
ThAnhonc
 
Object Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxObject Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptx
ethiouniverse
 
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
Markus Eisele
 
Lecture09.ppt
Lecture09.pptLecture09.ppt
Lecture09.ppt
hemanth248901
 
Java programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- InheritanceJava programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- Inheritance
Jyothishmathi Institute of Technology and Science Karimnagar
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbai
Unmesh Baile
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbai
vibrantuser
 
Lecture 1 - Objects and classes
Lecture 1 - Objects and classesLecture 1 - Objects and classes
Lecture 1 - Objects and classes
Syed Afaq Shah MACS CP
 

Similar to Lo5 (20)

Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentals
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in java
 
Concepts of oop1
Concepts of oop1Concepts of oop1
Concepts of oop1
 
Java chapter 5
Java chapter 5Java chapter 5
Java chapter 5
 
RIBBUN SOFTWARE
RIBBUN SOFTWARERIBBUN SOFTWARE
RIBBUN SOFTWARE
 
Java01
Java01Java01
Java01
 
Java01
Java01Java01
Java01
 
Introduction what is java
Introduction what is javaIntroduction what is java
Introduction what is java
 
Java01
Java01Java01
Java01
 
Java01
Java01Java01
Java01
 
Dewey Classification
Dewey ClassificationDewey Classification
Dewey Classification
 
Introducing classes
Introducing classesIntroducing classes
Introducing classes
 
BT02.pptx
BT02.pptxBT02.pptx
BT02.pptx
 
Object Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxObject Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptx
 
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
 
Lecture09.ppt
Lecture09.pptLecture09.ppt
Lecture09.ppt
 
Java programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- InheritanceJava programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- Inheritance
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbai
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbai
 
Lecture 1 - Objects and classes
Lecture 1 - Objects and classesLecture 1 - Objects and classes
Lecture 1 - Objects and classes
 

More from liankei

Lo 19
Lo 19Lo 19
Lo 19
liankei
 
Lo 18
Lo 18Lo 18
Lo 18
liankei
 
Lo 13
Lo 13Lo 13
Lo 13
liankei
 
Lo 12
Lo 12Lo 12
Lo 12
liankei
 
Lo 11
Lo 11Lo 11
Lo 11
liankei
 
Lo 06
Lo 06Lo 06
Lo 06
liankei
 
Lo 05
Lo 05Lo 05
Lo 05
liankei
 
Lo 04
Lo 04Lo 04
Lo 04
liankei
 
Lo 01
Lo 01Lo 01
Lo 01
liankei
 
Lo 16
Lo 16Lo 16
Lo 16
liankei
 
Lo 15
Lo 15Lo 15
Lo 15
liankei
 
Lo 09
Lo 09Lo 09
Lo 09
liankei
 
Lo 08
Lo 08Lo 08
Lo 08
liankei
 
Lo 03
Lo 03Lo 03
Lo 03
liankei
 
Lo 20
Lo 20Lo 20
Lo 20
liankei
 
Lo6
Lo6Lo6
Lo6
liankei
 

More from liankei (16)

Lo 19
Lo 19Lo 19
Lo 19
 
Lo 18
Lo 18Lo 18
Lo 18
 
Lo 13
Lo 13Lo 13
Lo 13
 
Lo 12
Lo 12Lo 12
Lo 12
 
Lo 11
Lo 11Lo 11
Lo 11
 
Lo 06
Lo 06Lo 06
Lo 06
 
Lo 05
Lo 05Lo 05
Lo 05
 
Lo 04
Lo 04Lo 04
Lo 04
 
Lo 01
Lo 01Lo 01
Lo 01
 
Lo 16
Lo 16Lo 16
Lo 16
 
Lo 15
Lo 15Lo 15
Lo 15
 
Lo 09
Lo 09Lo 09
Lo 09
 
Lo 08
Lo 08Lo 08
Lo 08
 
Lo 03
Lo 03Lo 03
Lo 03
 
Lo 20
Lo 20Lo 20
Lo 20
 
Lo6
Lo6Lo6
Lo6
 

Recently uploaded

What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 

Recently uploaded (20)

What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 

Lo5

  • 2. What is a class? • Early languages had only arrays – all elements had to be of the same type • Then languages introduced structures (called records, or structs) – allowed different data types to be grouped • Then Abstract Data Types (ADTs) became popular – grouped operations along with the data
  • 3. So, what is a class? • A class consists of – a collection of fields, or variables, very much like the named fields of a struct – all the operations (called methods) that can be performed on those fields – can be instantiated • A class describes objects and operations defined on those objects
  • 4. Name conventions • Java is case-sensitive; maxval, maxVal, and MaxVal are three different names • Class names begin with a capital letter • All other names begin with a lowercase letter • Subsequent words are capitalized: theBigOne • Underscores are not used in names • These are very strong conventions!
  • 5. The class hierarchy • Classes are arranged in a hierarchy • The root, or topmost, class is Object • Every class but Object has at least one superclass • A class may have subclasses • Each class inherits all the fields and methods of its (possibly numerous) superclasses
  • 6. An example of a class class Person { String name; int age; void birthday ( ) { age++; System.out.println (name + ' is now ' + age); } }
  • 7. Another example of a class class Driver extends Person { long driversLicenseNumber; Date expirationDate; }