SlideShare a Scribd company logo
1 of 6
Subject Code : 3630005
Subject Name : Java Programming
Unit 2 – Object Class
1
 Every class in Java has a direct super – class, if we do not
declare a super-class while defining a class then the
compiler assumes the Object class to be the super-class.
Only the Object class does not have any super-class.
 In Java any instance which is created has certain minimum
behaviour. When an instance of any reference type is
created, it has certain methods always available.
 These are the methods which are inherited from the Object
class. These methods are also available on instance of
arrays.
2
Object class is the root of the class hierarchy, defining the
minimum set of methods which should be available on any
instance in the JVM. Object is the super-type for all reference
types, i.e. any reference type is assignable to the Object.
3
 Methods Inherited from the Object Class
hashCode() : Every object in Java has an integer value
associated with it, which is known as hashCode value. This
method returns the hashCode value of the object, on which
the method is invoked. This method may be overridden. The
hashCode value is used by some of the data structure. The
method has the following signature:
public int hashCode()
This method is used in the Map implementation classes.
4
 toString() : In Java every data type can be converted to
String(has a String representation). For all instances the
toString() method is supported to return the String
representation of the instance. This method may be
overridden to define how instances of a given class should
be converted to String. The method has the following
signature:
public String toString()
5
 Some Methods of the Class CLASS
We know the instance of Class class is created in the JVM by the
class loader for every data type being used in the JVM. The
following are some of the common methods available in the Class
class:
6
Method Description
public String getName() Returns the name of the data type
public boolean isPrimitive() Check whether data type is primitive
public boolean isArray() Check whether it is an array type
public boolean isInterface() Check whether the data type is interface
public Class
getComponentType()
In case of array types, returns the element
type of the array
public Class getSuperClass() Returns the super class data type
public Class getInterfaces() Returns an array of the implement
interfaces

More Related Content

Similar to 4Unit - 2 The Object Class.pptx

Similar to 4Unit - 2 The Object Class.pptx (20)

Java Reflection
Java ReflectionJava Reflection
Java Reflection
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Oops
OopsOops
Oops
 
Java Advance Concepts
Java Advance ConceptsJava Advance Concepts
Java Advance Concepts
 
Java Unit 2(Part 1)
Java Unit 2(Part 1)Java Unit 2(Part 1)
Java Unit 2(Part 1)
 
Unit3 part1-class
Unit3 part1-classUnit3 part1-class
Unit3 part1-class
 
Java basics
Java basicsJava basics
Java basics
 
JVM
JVMJVM
JVM
 
Java
JavaJava
Java
 
Java14
Java14Java14
Java14
 
Java Interview Questions For Freshers
Java Interview Questions For FreshersJava Interview Questions For Freshers
Java Interview Questions For Freshers
 
M C6java3
M C6java3M C6java3
M C6java3
 
Java
JavaJava
Java
 
Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3
 
Java
JavaJava
Java
 
polymorphism method overloading and overriding .pptx
polymorphism method overloading  and overriding .pptxpolymorphism method overloading  and overriding .pptx
polymorphism method overloading and overriding .pptx
 
Ruby object model
Ruby object modelRuby object model
Ruby object model
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 

Recently uploaded (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 

4Unit - 2 The Object Class.pptx

  • 1. Subject Code : 3630005 Subject Name : Java Programming Unit 2 – Object Class 1
  • 2.  Every class in Java has a direct super – class, if we do not declare a super-class while defining a class then the compiler assumes the Object class to be the super-class. Only the Object class does not have any super-class.  In Java any instance which is created has certain minimum behaviour. When an instance of any reference type is created, it has certain methods always available.  These are the methods which are inherited from the Object class. These methods are also available on instance of arrays. 2
  • 3. Object class is the root of the class hierarchy, defining the minimum set of methods which should be available on any instance in the JVM. Object is the super-type for all reference types, i.e. any reference type is assignable to the Object. 3
  • 4.  Methods Inherited from the Object Class hashCode() : Every object in Java has an integer value associated with it, which is known as hashCode value. This method returns the hashCode value of the object, on which the method is invoked. This method may be overridden. The hashCode value is used by some of the data structure. The method has the following signature: public int hashCode() This method is used in the Map implementation classes. 4
  • 5.  toString() : In Java every data type can be converted to String(has a String representation). For all instances the toString() method is supported to return the String representation of the instance. This method may be overridden to define how instances of a given class should be converted to String. The method has the following signature: public String toString() 5
  • 6.  Some Methods of the Class CLASS We know the instance of Class class is created in the JVM by the class loader for every data type being used in the JVM. The following are some of the common methods available in the Class class: 6 Method Description public String getName() Returns the name of the data type public boolean isPrimitive() Check whether data type is primitive public boolean isArray() Check whether it is an array type public boolean isInterface() Check whether the data type is interface public Class getComponentType() In case of array types, returns the element type of the array public Class getSuperClass() Returns the super class data type public Class getInterfaces() Returns an array of the implement interfaces