SlideShare a Scribd company logo
1 of 18
Object Oriented Programming in Java
 OOP is a programming paradigm
 What is programming paradigm
 A method or way to write a computer program for real world applications.
 Is there any other programming paradigm exists
 Yes
 Which one?
 Structure programming
 Functional programming
 Procedural programming
 Logical programming
 Code Reusability
 Practical approach
 Code maintenance
 Security
 Design benefits
 Better productivity
 Modularity
 Classes
 Objects & methods
 Inheritance
 Polymorphism
 Abstraction
 Encapsulation
Mastering these concepts means you are going to become an expert programmer in
industry soon.
 To understand OOP concepts relate them with real world.
 Whatever you do in your real world is actually one of the OOP concept.
 Smalltalk is first and purely OOP language.
 JAVA, C#, C++, Python etc these all are OOP languages.
 In real world class means a presentation for the group of some related objects like
 Animals class
 Birds class
 Vehicles class
 Human class, etc.
 For example if we talk about animal class than which objects should fall in this class
 Dog
 Cat
 Horse
 Tiger, etc.
 For example in bird class objects should be
 Sparrow
 Peacock
 Parrot
 Owl, etc.
 A class represents some methods/activities that the objects of that class follow, for
example
 Animals can (eat, run, walk, drink, fight, etc)
 Birds can (fly, eat, walk, drink, etc)
 Humans can (eat, run, walk, drink, fight, read, etc)
 Class is the collection of objects.
 Class is not the real world entity, it is just the template or blueprint.*
 Class does not occupy memory.**
access-modifiers class ClassName
{
Class body (methods, constructors, fields, blocks, nested class);
}
 In case of no access-modifier will written the default access modifier will be
considered.
 Method is a set of code which perform a particular task.
 Example eat(), run(), walk(), etc.
 Advantages of methods:
 Code reusability
 Code Optimization
access-modifier return-type methodName (list of parameters)
{
Method body(conditional, switch, control statements, variables etc)
}
If no access-modifier place the default modifier will take place in java.
 Object is an instance of class e.g. dog is an instance of animal.
 Object is real world entity.
 Object occupies memory.
 Identity: name
 State/Attribute: Breed, Age, Color
 Behaviors: Eat(), Run(), Bark()
 There are five ways to create object in java
 By using new keywords
 By using newInstance() method
 By using clone() method
 By using deserialization
 Mainly objects created by using new keyword.
 Declaration
 Declare variable that represent the object name. For example
 Animal buzo;
 Instantiation and Initialization (Initialization perform by using class name constructor.
 )
 buzo = new Animal();
 By combining declaration, instantiation and initialization the object can be create using
following syntax.
 Animal buzo = new Animal();
 The behavior/method of object call by using dot (.) operator.
 For example
 buzo.run()
 buzo.eat()
How to change the state/attribute of an object?
 The state/attribute of object can also be change by using dot(.) operator.
 For example
 buzo.color = black;
 buzo.age=3;
public class Animal
{
Int age = 1;
String breed = “GS”;
public void eat()
{
System.out.println(“I am eating”);
}
public void run()
{
System.out.println(“I am running”);
}
}
public static void main (String args[])
{
Animal dog = new Animal();
System.out.println(dog.age);
System.out.println(dog.breed);
dog.run();
dog.eat();
}

More Related Content

What's hot

Ontology Engineering: representation in OWL
Ontology Engineering: representation in OWLOntology Engineering: representation in OWL
Ontology Engineering: representation in OWLGuus Schreiber
 
Pi j3.1 inheritance
Pi j3.1 inheritancePi j3.1 inheritance
Pi j3.1 inheritancemcollison
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#Doncho Minkov
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentalsAnsgarMary
 
Concept of OOPS with real life examples
Concept of OOPS with real life examplesConcept of OOPS with real life examples
Concept of OOPS with real life examplesNeha Sharma
 
Object oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyayObject oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyaySaurabh Upadhyay
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingMoutaz Haddara
 
Object-Oriented Programming with C#
Object-Oriented Programming with C#Object-Oriented Programming with C#
Object-Oriented Programming with C#Svetlin Nakov
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming ConceptsAbhigyan Singh Yadav
 
Polymorphism in Python
Polymorphism in Python Polymorphism in Python
Polymorphism in Python Home
 
Class, object and inheritance in python
Class, object and inheritance in pythonClass, object and inheritance in python
Class, object and inheritance in pythonSantosh Verma
 
Methods and constructors
Methods and constructorsMethods and constructors
Methods and constructorsRavi_Kant_Sahu
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingMd. Tanvir Hossain
 

What's hot (20)

Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
Ontology Engineering: representation in OWL
Ontology Engineering: representation in OWLOntology Engineering: representation in OWL
Ontology Engineering: representation in OWL
 
Pi j3.1 inheritance
Pi j3.1 inheritancePi j3.1 inheritance
Pi j3.1 inheritance
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentals
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lecture 1 - Objects and classes
Lecture 1 - Objects and classesLecture 1 - Objects and classes
Lecture 1 - Objects and classes
 
Concept of OOPS with real life examples
Concept of OOPS with real life examplesConcept of OOPS with real life examples
Concept of OOPS with real life examples
 
Object oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyayObject oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh Upadhyay
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 
Class
ClassClass
Class
 
Object-Oriented Programming with C#
Object-Oriented Programming with C#Object-Oriented Programming with C#
Object-Oriented Programming with C#
 
Ontology engineering
Ontology engineering Ontology engineering
Ontology engineering
 
OOPS Characteristics
OOPS CharacteristicsOOPS Characteristics
OOPS Characteristics
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Polymorphism in Python
Polymorphism in Python Polymorphism in Python
Polymorphism in Python
 
Class, object and inheritance in python
Class, object and inheritance in pythonClass, object and inheritance in python
Class, object and inheritance in python
 
Computer programming 2 Lesson 3
Computer programming 2  Lesson 3Computer programming 2  Lesson 3
Computer programming 2 Lesson 3
 
Methods and constructors
Methods and constructorsMethods and constructors
Methods and constructors
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 

Similar to OOP Basic Concepts

Java OOPs Concepts.docx
Java OOPs Concepts.docxJava OOPs Concepts.docx
Java OOPs Concepts.docxFredWauyo
 
Learn Polymorphism in Python with Examples.pdf
Learn Polymorphism in Python with Examples.pdfLearn Polymorphism in Python with Examples.pdf
Learn Polymorphism in Python with Examples.pdfDatacademy.ai
 
Java Script Patterns
Java Script PatternsJava Script Patterns
Java Script PatternsAllan Huang
 
Object oriented programming tutorial
Object oriented programming tutorialObject oriented programming tutorial
Object oriented programming tutorialGhulam Abbas Khan
 
Java is an Object-Oriented Language
Java is an Object-Oriented LanguageJava is an Object-Oriented Language
Java is an Object-Oriented Languageale8819
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaMadishetty Prathibha
 
Python programming computer science and engineering
Python programming computer science and engineeringPython programming computer science and engineering
Python programming computer science and engineeringIRAH34
 
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Ayes Chinmay
 
Lect 1-java object-classes
Lect 1-java object-classesLect 1-java object-classes
Lect 1-java object-classesFajar Baskoro
 
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...AnkurSingh340457
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)Khaled Anaqwa
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaSujit Majety
 
Regex,functions, inheritance,class, attribute,overloding
Regex,functions, inheritance,class, attribute,overlodingRegex,functions, inheritance,class, attribute,overloding
Regex,functions, inheritance,class, attribute,overlodingsangumanikesh
 
Modern_2.pptx for java
Modern_2.pptx for java Modern_2.pptx for java
Modern_2.pptx for java MayaTofik
 

Similar to OOP Basic Concepts (20)

Java OOPs Concepts.docx
Java OOPs Concepts.docxJava OOPs Concepts.docx
Java OOPs Concepts.docx
 
Oop java
Oop javaOop java
Oop java
 
Learn Polymorphism in Python with Examples.pdf
Learn Polymorphism in Python with Examples.pdfLearn Polymorphism in Python with Examples.pdf
Learn Polymorphism in Python with Examples.pdf
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Java Script Patterns
Java Script PatternsJava Script Patterns
Java Script Patterns
 
Object oriented programming tutorial
Object oriented programming tutorialObject oriented programming tutorial
Object oriented programming tutorial
 
Java is an Object-Oriented Language
Java is an Object-Oriented LanguageJava is an Object-Oriented Language
Java is an Object-Oriented Language
 
java
javajava
java
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
 
Python programming computer science and engineering
Python programming computer science and engineeringPython programming computer science and engineering
Python programming computer science and engineering
 
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
 
Lect 1-java object-classes
Lect 1-java object-classesLect 1-java object-classes
Lect 1-java object-classes
 
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
 
Computer Programming 2
Computer Programming 2 Computer Programming 2
Computer Programming 2
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Regex,functions, inheritance,class, attribute,overloding
Regex,functions, inheritance,class, attribute,overlodingRegex,functions, inheritance,class, attribute,overloding
Regex,functions, inheritance,class, attribute,overloding
 
2.oop concept
2.oop concept2.oop concept
2.oop concept
 
Modern_2.pptx for java
Modern_2.pptx for java Modern_2.pptx for java
Modern_2.pptx for java
 
Java script unleashed
Java script unleashedJava script unleashed
Java script unleashed
 

Recently uploaded

Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIkoyaldeepu123
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage examplePragyanshuParadkar1
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixingviprabot1
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 

Recently uploaded (20)

Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AI
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage example
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixing
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 

OOP Basic Concepts

  • 2.  OOP is a programming paradigm  What is programming paradigm  A method or way to write a computer program for real world applications.  Is there any other programming paradigm exists  Yes  Which one?  Structure programming  Functional programming  Procedural programming  Logical programming
  • 3.  Code Reusability  Practical approach  Code maintenance  Security  Design benefits  Better productivity  Modularity
  • 4.  Classes  Objects & methods  Inheritance  Polymorphism  Abstraction  Encapsulation Mastering these concepts means you are going to become an expert programmer in industry soon.
  • 5.  To understand OOP concepts relate them with real world.  Whatever you do in your real world is actually one of the OOP concept.
  • 6.  Smalltalk is first and purely OOP language.  JAVA, C#, C++, Python etc these all are OOP languages.
  • 7.  In real world class means a presentation for the group of some related objects like  Animals class  Birds class  Vehicles class  Human class, etc.  For example if we talk about animal class than which objects should fall in this class  Dog  Cat  Horse  Tiger, etc.
  • 8.  For example in bird class objects should be  Sparrow  Peacock  Parrot  Owl, etc.  A class represents some methods/activities that the objects of that class follow, for example  Animals can (eat, run, walk, drink, fight, etc)  Birds can (fly, eat, walk, drink, etc)  Humans can (eat, run, walk, drink, fight, read, etc)
  • 9.  Class is the collection of objects.  Class is not the real world entity, it is just the template or blueprint.*  Class does not occupy memory.**
  • 10. access-modifiers class ClassName { Class body (methods, constructors, fields, blocks, nested class); }  In case of no access-modifier will written the default access modifier will be considered.
  • 11.  Method is a set of code which perform a particular task.  Example eat(), run(), walk(), etc.  Advantages of methods:  Code reusability  Code Optimization
  • 12. access-modifier return-type methodName (list of parameters) { Method body(conditional, switch, control statements, variables etc) } If no access-modifier place the default modifier will take place in java.
  • 13.  Object is an instance of class e.g. dog is an instance of animal.  Object is real world entity.  Object occupies memory.
  • 14.  Identity: name  State/Attribute: Breed, Age, Color  Behaviors: Eat(), Run(), Bark()
  • 15.  There are five ways to create object in java  By using new keywords  By using newInstance() method  By using clone() method  By using deserialization  Mainly objects created by using new keyword.
  • 16.  Declaration  Declare variable that represent the object name. For example  Animal buzo;  Instantiation and Initialization (Initialization perform by using class name constructor.  )  buzo = new Animal();  By combining declaration, instantiation and initialization the object can be create using following syntax.  Animal buzo = new Animal();
  • 17.  The behavior/method of object call by using dot (.) operator.  For example  buzo.run()  buzo.eat() How to change the state/attribute of an object?  The state/attribute of object can also be change by using dot(.) operator.  For example  buzo.color = black;  buzo.age=3;
  • 18. public class Animal { Int age = 1; String breed = “GS”; public void eat() { System.out.println(“I am eating”); } public void run() { System.out.println(“I am running”); } } public static void main (String args[]) { Animal dog = new Animal(); System.out.println(dog.age); System.out.println(dog.breed); dog.run(); dog.eat(); }

Editor's Notes

  1. *(if I want to see the animals I will see the objects, word animal is nothing but representation of a group of objects) **because only real entities occupy space in real world.
  2. *Four access modifiers in java Default Public Private protected