SlideShare a Scribd company logo
OBJECT ORIENTED PROGRAMMING
INDEX  UNIT 1 PPT SLIDES S.NO.  TOPIC  LECTURE NO.  PPTSLIDES Need for oop paradigm,    L1   L1.1TO L1.4 A way of viewing world – Agents Responsibility, Messages, Methods  L2   L2.1 TO L2.3 classes and instances,      L3   L3.1 TO L3.6 class hierarchies, Inheritance method binding    L 4   L4.1 TO L4.5 overriding and exceptions summary of oop concepts, coping with complexity,    L5 L5.1 TO 5.4 abstraction mechanisms
Need for OOP Paradigm OOP is an approach to program organization and development, which attempts  to eliminate some of the drawbacks of conventional programming methods by incorporating the best of structured programming features with several new concepts. OOP allows us to decompose a problem into number of entities called objects and then build data and methods (functions) around these entities. The data of an object can be accessed only by the methods associated with the object.
Some of the Object-Oriented Paradigm are: Emphasis is on data rather than procedure. Programs are divided into objects. Data Structures are designed such that they Characterize the objects. Methods that operate on the data of an object  are tied together in the data structure. Data is hidden and can not be accessed by external functions. Objects may communicate with each other through methods.
A way of viewing world – Agents OOP uses an approach of treating a real world agent as an object. Object-oriented programming organizes a program around its data (that is, objects) and a set of well-defined interfaces to that data.  An object-oriented program can be characterized as  data controlling access to code  by switching the controlling entity to data.
 
Responsibility  primary motivation is the need for a platform-independent (that is, architecture- neutral) language that could be used to create software to be embedded in various consumer electronic devices, such as microwave ovens and remote controls. Objects with clear responsibilities  Each class should have a clear responsibility. If you can't state the purpose of a class in a single, clear sentence, then perhaps your class structure needs some thought.
Messages We all like to use programs that let us know what's going on. Programs that keep us informed often do so by displaying status and error messages.  These messages need to be translated so they can be understood by end users around the world.  The Section discusses translatable text messages. Usually, you're done after you move a message String into a ResourceBundle. If you've embedded variable data in a message, you'll have to take some extra steps to prepare it for translation.
Methods A method is a group of instructions that is given a name and can be called up at any point in a program simply by quoting that name.  Drawing a Triangle require draw of three straight lines. This instruction three times to draw a simple triangle. We can define a method to call this instruction three times and draw the triangle(i.e. create a method drawLine() to draw lines and this method is called repeatedly to achieve the needed task) The idea of methods appears in all programming languages, although sometimes it goes under the name  functions  and sometimes under the name  procedures . The name  methods  is a throw-back to the language C++, from which Java was developed.  In C++, there is an object called a  class  which can contain methods. However, everything in Java is enclosed within a class .so the functions within it are called methods
CLASSES Class is blue print or an idea of an Object From One class any number of Instances can be created It is an encapsulation of attributes and methods FIGURE CIRCLE RECTANGLE SQUARE Ob1 Ob2 Ob3 class
syntax of CLASS class <ClassName> { attributes/variables; Constructors(); methods(); }
INSTANCE Instance is an Object of a class which is an entity with its own attribute values and methods. Creating an Instance ClassName refVariable; refVariable = new Constructor(); or ClassName  refVariable = new  Constructor();
Java Class Hierarchy In Java, class “Object” is the base class to all other classes If we do not explicitly say extends in a new class definition, it implicitly extends Object The tree of classes that extend from Object and all of its subclasses are is called the class hierarchy All classes eventually lead back up to Object This will enable consistent access of objects of different classes.
Inheritance Methods allows to reuse a sequence of statements Inheritance  allows to reuse classes by deriving a new class from an existing one The existing class is called the  parent class,  or  superclass , or  base class The derived class is called the  child class  or  subclass . The child class inherits characteristics of the parent class(i.e  the child class  inherits  the methods and data defined for the parent class
Inheritance Inheritance relationships are often shown graphically in a  class diagram , with the arrow pointing to the parent class + fly() : void Animal weight : int + getWeight() : int Bird
Method Binding Objects are used to call methods. MethodBinding  is an object that can be used to call an arbitrary public method, on an instance that is acquired by evaluatng the leading portion of a method binding expression via a value binding.  It is legal for a class to have two or more methods with the same name. Java has to be able to uniquely associate the invocation of a method with its definition relying on the number and types of arguments. Therefore the same-named methods must be distinguished: 1) by the number of arguments, or 2) by the types of arguments Overloading and inheritance are two ways to implement polymorphism.
Method Overriding. There may be some occasions when we want an object to respond to the same method but have different behaviour when that method is called. That means, we should override the method defined in the superclass. This is possible by defining a method in a sub class that has the same name, same arguments and same return type as a method in the superclass. Then when that method is called, the method defined in the sub class is invoked and executed instead of the one in the superclass. This is known as overriding.
Exceptions in Java Exception is an abnormal condition that arises in the code sequence. Exceptions occur during compile time or run time. “ throwable” is the super class in exception hierarchy.  Compile time errors occurs due to incorrect syntax. Run-time errors happen when User enters incorrect input Resource is not available (ex. file) Logic error (bug) that was not fixed
Exception classes In Java, exceptions are objects. When you throw an exception, you throw an object. You can't throw just any object as an exception, however -- only those objects whose classes descend from Throwable. Throwable serves as the base class for an entire family of classes, declared in java.lang, that your program can instantiate and throw.  Throwable has two direct subclasses, Exception and Error. Exceptions are thrown to signal abnormal conditions that can often be handled by some catcher, though it's possible they may not be caught and therefore could result in a dead thread. Errors are usually thrown for more serious problems, such as OutOfMemoryError, that may not be so easy to handle. In general, code you write should throw only exceptions, not errors.  Errors are usually thrown by the methods of the Java API, or by the Java virtual machine itself.
 
Summary of  OOPS The following are the basic oops concepts: They are as follows: Objects. Classes. Data Abstraction. Data Encapsulation. Inheritance. Polymorphism. Dynamic Binding. Message Passing.
Abstraction in Object-Oriented Programming Procedural Abstraction Procedural Abstractions organize instructions. Function Power Give me two numbers (base & exponent) I’ll return  base exponent Implementation
Data Abstraction Data Abstractions organize data. Name (string) Marks (num) Grade (char) Student Number (num) StudentType
Behavioral Abstraction Behavioral Abstractions combine procedural and data abstractions. Data State Enqueue Is Full Is Empty Dequeue Initialize Queue Object
Ad

More Related Content

What's hot (20)

Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
jaimefrozr
 
Java Notes
Java NotesJava Notes
Java Notes
Abhishek Khune
 
Chapter 1 swings
Chapter 1 swingsChapter 1 swings
Chapter 1 swings
Jafar Nesargi
 
Method Overloading In Java
Method Overloading In JavaMethod Overloading In Java
Method Overloading In Java
CharthaGaglani
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Java-java virtual machine
Java-java virtual machineJava-java virtual machine
Java-java virtual machine
Surbhi Panhalkar
 
Uml in software engineering
Uml in software engineeringUml in software engineering
Uml in software engineering
Mubashir Jutt
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
Md.Al-imran Roton
 
Programming in Java
Programming in JavaProgramming in Java
Programming in Java
Abhilash Nair
 
Packages in java
Packages in javaPackages in java
Packages in java
Jancypriya M
 
Operators in java
Operators in javaOperators in java
Operators in java
Muthukumaran Subramanian
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
Math-Circle
 
Object Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaionObject Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaion
Pritom Chaki
 
Lecture_7-Encapsulation in Java.pptx
Lecture_7-Encapsulation in Java.pptxLecture_7-Encapsulation in Java.pptx
Lecture_7-Encapsulation in Java.pptx
ShahinAhmed49
 
Java
JavaJava
Java
Tony Nguyen
 
Control statements in java
Control statements in javaControl statements in java
Control statements in java
Madishetty Prathibha
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
Hitesh Kumar
 
Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
atozknowledge .com
 
Managing I/O in c++
Managing I/O in c++Managing I/O in c++
Managing I/O in c++
Pranali Chaudhari
 
Introduction To Python
Introduction To PythonIntroduction To Python
Introduction To Python
Vanessa Rene
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
jaimefrozr
 
Method Overloading In Java
Method Overloading In JavaMethod Overloading In Java
Method Overloading In Java
CharthaGaglani
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Uml in software engineering
Uml in software engineeringUml in software engineering
Uml in software engineering
Mubashir Jutt
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
Md.Al-imran Roton
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
Math-Circle
 
Object Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaionObject Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaion
Pritom Chaki
 
Lecture_7-Encapsulation in Java.pptx
Lecture_7-Encapsulation in Java.pptxLecture_7-Encapsulation in Java.pptx
Lecture_7-Encapsulation in Java.pptx
ShahinAhmed49
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
Hitesh Kumar
 
Introduction To Python
Introduction To PythonIntroduction To Python
Introduction To Python
Vanessa Rene
 

Similar to Unit 1 Java (20)

JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
AnmolVerma363503
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxJAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptx
KunalYadav65140
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptx
RaazIndia
 
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
UNIT I 	OOP AND JAVA FUNDAMENTALS CONSTRUCTORUNIT I 	OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
mohanrajm63
 
VTU JAVA PPT BY DJ AND BEST PPT C ON JAVA
VTU JAVA PPT BY DJ AND BEST PPT C ON JAVAVTU JAVA PPT BY DJ AND BEST PPT C ON JAVA
VTU JAVA PPT BY DJ AND BEST PPT C ON JAVA
dsajadhav369
 
JAVA_8_.ppt all introduction to java topics
JAVA_8_.ppt all introduction to java  topicsJAVA_8_.ppt all introduction to java  topics
JAVA_8_.ppt all introduction to java topics
TamizharasiA1
 
Oop
OopOop
Oop
Jun-jun Lagman
 
Suga java training_with_footer
Suga java training_with_footerSuga java training_with_footer
Suga java training_with_footer
Sugavanam Natarajan
 
Review oop and ood
Review oop and oodReview oop and ood
Review oop and ood
than sare
 
Oop basic concepts
Oop basic conceptsOop basic concepts
Oop basic concepts
Swarup Kumar Boro
 
Java Interview Questions For Freshers
Java Interview Questions For FreshersJava Interview Questions For Freshers
Java Interview Questions For Freshers
zynofustechnology
 
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
 
Question and answer Programming
Question and answer ProgrammingQuestion and answer Programming
Question and answer Programming
Inocentshuja Ahmad
 
Selenium Training .pptx
Selenium Training .pptxSelenium Training .pptx
Selenium Training .pptx
SajidTk2
 
2.oop concept
2.oop concept2.oop concept
2.oop concept
Robbie AkaChopa
 
Java mcq
Java mcqJava mcq
Java mcq
avinash9821
 
My c++
My c++My c++
My c++
snathick
 
OOPS 46 slide Python concepts .pptx
OOPS 46 slide Python concepts       .pptxOOPS 46 slide Python concepts       .pptx
OOPS 46 slide Python concepts .pptx
mrsam3062
 
Object oriented programming in python
Object oriented programming in pythonObject oriented programming in python
Object oriented programming in python
nitamhaske
 
Oops concepts
Oops conceptsOops concepts
Oops concepts
ACCESS Health Digital
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxJAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptx
KunalYadav65140
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptx
RaazIndia
 
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
UNIT I 	OOP AND JAVA FUNDAMENTALS CONSTRUCTORUNIT I 	OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
mohanrajm63
 
VTU JAVA PPT BY DJ AND BEST PPT C ON JAVA
VTU JAVA PPT BY DJ AND BEST PPT C ON JAVAVTU JAVA PPT BY DJ AND BEST PPT C ON JAVA
VTU JAVA PPT BY DJ AND BEST PPT C ON JAVA
dsajadhav369
 
JAVA_8_.ppt all introduction to java topics
JAVA_8_.ppt all introduction to java  topicsJAVA_8_.ppt all introduction to java  topics
JAVA_8_.ppt all introduction to java topics
TamizharasiA1
 
Review oop and ood
Review oop and oodReview oop and ood
Review oop and ood
than sare
 
Java Interview Questions For Freshers
Java Interview Questions For FreshersJava Interview Questions For Freshers
Java Interview Questions For Freshers
zynofustechnology
 
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
 
Question and answer Programming
Question and answer ProgrammingQuestion and answer Programming
Question and answer Programming
Inocentshuja Ahmad
 
Selenium Training .pptx
Selenium Training .pptxSelenium Training .pptx
Selenium Training .pptx
SajidTk2
 
OOPS 46 slide Python concepts .pptx
OOPS 46 slide Python concepts       .pptxOOPS 46 slide Python concepts       .pptx
OOPS 46 slide Python concepts .pptx
mrsam3062
 
Object oriented programming in python
Object oriented programming in pythonObject oriented programming in python
Object oriented programming in python
nitamhaske
 
Ad

More from arnold 7490 (20)

Les14
Les14Les14
Les14
arnold 7490
 
Les13
Les13Les13
Les13
arnold 7490
 
Les11
Les11Les11
Les11
arnold 7490
 
Les10
Les10Les10
Les10
arnold 7490
 
Les09
Les09Les09
Les09
arnold 7490
 
Les03
Les03Les03
Les03
arnold 7490
 
Les02
Les02Les02
Les02
arnold 7490
 
Les01
Les01Les01
Les01
arnold 7490
 
Les12
Les12Les12
Les12
arnold 7490
 
Unit 8 Java
Unit 8 JavaUnit 8 Java
Unit 8 Java
arnold 7490
 
Unit 5 Java
Unit 5 JavaUnit 5 Java
Unit 5 Java
arnold 7490
 
Unit 4 Java
Unit 4 JavaUnit 4 Java
Unit 4 Java
arnold 7490
 
Unit 3 Java
Unit 3 JavaUnit 3 Java
Unit 3 Java
arnold 7490
 
Unit6 C
Unit6 C Unit6 C
Unit6 C
arnold 7490
 
Unit5 C
Unit5 C Unit5 C
Unit5 C
arnold 7490
 
Unit4 C
Unit4 C Unit4 C
Unit4 C
arnold 7490
 
Ad

Unit 1 Java

  • 2. INDEX UNIT 1 PPT SLIDES S.NO. TOPIC LECTURE NO. PPTSLIDES Need for oop paradigm, L1 L1.1TO L1.4 A way of viewing world – Agents Responsibility, Messages, Methods L2 L2.1 TO L2.3 classes and instances, L3 L3.1 TO L3.6 class hierarchies, Inheritance method binding L 4 L4.1 TO L4.5 overriding and exceptions summary of oop concepts, coping with complexity, L5 L5.1 TO 5.4 abstraction mechanisms
  • 3. Need for OOP Paradigm OOP is an approach to program organization and development, which attempts to eliminate some of the drawbacks of conventional programming methods by incorporating the best of structured programming features with several new concepts. OOP allows us to decompose a problem into number of entities called objects and then build data and methods (functions) around these entities. The data of an object can be accessed only by the methods associated with the object.
  • 4. Some of the Object-Oriented Paradigm are: Emphasis is on data rather than procedure. Programs are divided into objects. Data Structures are designed such that they Characterize the objects. Methods that operate on the data of an object are tied together in the data structure. Data is hidden and can not be accessed by external functions. Objects may communicate with each other through methods.
  • 5. A way of viewing world – Agents OOP uses an approach of treating a real world agent as an object. Object-oriented programming organizes a program around its data (that is, objects) and a set of well-defined interfaces to that data. An object-oriented program can be characterized as data controlling access to code by switching the controlling entity to data.
  • 6.  
  • 7. Responsibility primary motivation is the need for a platform-independent (that is, architecture- neutral) language that could be used to create software to be embedded in various consumer electronic devices, such as microwave ovens and remote controls. Objects with clear responsibilities Each class should have a clear responsibility. If you can't state the purpose of a class in a single, clear sentence, then perhaps your class structure needs some thought.
  • 8. Messages We all like to use programs that let us know what's going on. Programs that keep us informed often do so by displaying status and error messages. These messages need to be translated so they can be understood by end users around the world. The Section discusses translatable text messages. Usually, you're done after you move a message String into a ResourceBundle. If you've embedded variable data in a message, you'll have to take some extra steps to prepare it for translation.
  • 9. Methods A method is a group of instructions that is given a name and can be called up at any point in a program simply by quoting that name. Drawing a Triangle require draw of three straight lines. This instruction three times to draw a simple triangle. We can define a method to call this instruction three times and draw the triangle(i.e. create a method drawLine() to draw lines and this method is called repeatedly to achieve the needed task) The idea of methods appears in all programming languages, although sometimes it goes under the name functions and sometimes under the name procedures . The name methods is a throw-back to the language C++, from which Java was developed. In C++, there is an object called a class which can contain methods. However, everything in Java is enclosed within a class .so the functions within it are called methods
  • 10. CLASSES Class is blue print or an idea of an Object From One class any number of Instances can be created It is an encapsulation of attributes and methods FIGURE CIRCLE RECTANGLE SQUARE Ob1 Ob2 Ob3 class
  • 11. syntax of CLASS class <ClassName> { attributes/variables; Constructors(); methods(); }
  • 12. INSTANCE Instance is an Object of a class which is an entity with its own attribute values and methods. Creating an Instance ClassName refVariable; refVariable = new Constructor(); or ClassName refVariable = new Constructor();
  • 13. Java Class Hierarchy In Java, class “Object” is the base class to all other classes If we do not explicitly say extends in a new class definition, it implicitly extends Object The tree of classes that extend from Object and all of its subclasses are is called the class hierarchy All classes eventually lead back up to Object This will enable consistent access of objects of different classes.
  • 14. Inheritance Methods allows to reuse a sequence of statements Inheritance allows to reuse classes by deriving a new class from an existing one The existing class is called the parent class, or superclass , or base class The derived class is called the child class or subclass . The child class inherits characteristics of the parent class(i.e the child class inherits the methods and data defined for the parent class
  • 15. Inheritance Inheritance relationships are often shown graphically in a class diagram , with the arrow pointing to the parent class + fly() : void Animal weight : int + getWeight() : int Bird
  • 16. Method Binding Objects are used to call methods. MethodBinding is an object that can be used to call an arbitrary public method, on an instance that is acquired by evaluatng the leading portion of a method binding expression via a value binding. It is legal for a class to have two or more methods with the same name. Java has to be able to uniquely associate the invocation of a method with its definition relying on the number and types of arguments. Therefore the same-named methods must be distinguished: 1) by the number of arguments, or 2) by the types of arguments Overloading and inheritance are two ways to implement polymorphism.
  • 17. Method Overriding. There may be some occasions when we want an object to respond to the same method but have different behaviour when that method is called. That means, we should override the method defined in the superclass. This is possible by defining a method in a sub class that has the same name, same arguments and same return type as a method in the superclass. Then when that method is called, the method defined in the sub class is invoked and executed instead of the one in the superclass. This is known as overriding.
  • 18. Exceptions in Java Exception is an abnormal condition that arises in the code sequence. Exceptions occur during compile time or run time. “ throwable” is the super class in exception hierarchy. Compile time errors occurs due to incorrect syntax. Run-time errors happen when User enters incorrect input Resource is not available (ex. file) Logic error (bug) that was not fixed
  • 19. Exception classes In Java, exceptions are objects. When you throw an exception, you throw an object. You can't throw just any object as an exception, however -- only those objects whose classes descend from Throwable. Throwable serves as the base class for an entire family of classes, declared in java.lang, that your program can instantiate and throw. Throwable has two direct subclasses, Exception and Error. Exceptions are thrown to signal abnormal conditions that can often be handled by some catcher, though it's possible they may not be caught and therefore could result in a dead thread. Errors are usually thrown for more serious problems, such as OutOfMemoryError, that may not be so easy to handle. In general, code you write should throw only exceptions, not errors. Errors are usually thrown by the methods of the Java API, or by the Java virtual machine itself.
  • 20.  
  • 21. Summary of OOPS The following are the basic oops concepts: They are as follows: Objects. Classes. Data Abstraction. Data Encapsulation. Inheritance. Polymorphism. Dynamic Binding. Message Passing.
  • 22. Abstraction in Object-Oriented Programming Procedural Abstraction Procedural Abstractions organize instructions. Function Power Give me two numbers (base & exponent) I’ll return base exponent Implementation
  • 23. Data Abstraction Data Abstractions organize data. Name (string) Marks (num) Grade (char) Student Number (num) StudentType
  • 24. Behavioral Abstraction Behavioral Abstractions combine procedural and data abstractions. Data State Enqueue Is Full Is Empty Dequeue Initialize Queue Object
  翻译: