OOP in java


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

OOP in java

  1. 1. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  2. 2. Typing Speed Week Target Achieved 1 25WPM 18WPM 2 25WPM 19WPM 3 25WPM 20WPM 4 25WPM 21WPM 5 25wpm 21wpm 6 25wpm 21wpm 7 25wpm 22wpm 8 25wpm 22wpm 9 25wpm 23wpm 10 25wpm 23wpm
  3. 3. Object-Oriented Programming MEENU SOMAN.P meenusoman99@gmail.com www.facebook.com/MEENU SOMAN twitter.com/username in.linkedin.com/in/profilena me 8943031867
  4. 4. What is OOP?  Object-oriented programming (OOP)style of programming that focuses on using objects to design and build applications.  Think of an object as a model of the concepts,processes, or thing in the real world that are meaningful to your application
  5. 5. What Are Objects?  Software objects model reaL-world objects - dog, bicycle, etc.  Real-world objects have states and behaviors -Dogs' states or properties: name, color, breed, hungry -Dogs' behaviors or action : barking fetching  How do Software objects implement real-world objects? -Use variables to implement states -Use methods to implement behaviors  An object is a software bundle of variables and related methods
  6. 6. Definition • Class : -is the base design of objects • Object :- is the instance of a class • No memory is allocated when a class is created. • Memory is allocated only when an object is created.
  7. 7. Constructor  A method in a class that initialize an instance of an object before it's used. • The same name as the class and have no return type  Multiple Constructors: the same name but a different number of arguments or different typed arguments • Method Overloading  Java Provides default constructors.  The special variable, this, can be used inside a method to refer to the object instance
  8. 8. Example for Constructor • Public class shape { private int width; private int height; shape(int height,int width) { this.width=width; this.height=height; } Private int calculateArea() { return a*b; } } Shape rectangle=new shape(20,35);
  9. 9. OOP FEATURES Abstraction Encapsulation Polymorphism Inheritance
  10. 10. Data Abstraction  Abstraction refers to the act of representing essential features without including the background details or explanations.  Since the classes use the concept of data abstraction , they are known as the abstract data types.
  11. 11. Encapsulation  The wrapping up of data and functions into a single unit is known as Encapsulation.  The data is not accessible to the outside world and only those functions which are wrapped in the class can access it.  This insulation of the data from direct access by the program is called Data hiding or information hiding.
  12. 12. Polymorphism  In polymorphism refers to a programming language ability to process objects differently depending on their data type or class.  More specifically, it is the ability to redefine methods for derived classes.  For example, given a base class shape , polymorphism enables the programmer to define different area methods for any number of derived classes, such as circles, rectangles and triangles. No matter what shape an object is, applying the area method to it will return the correct results. Polymorphism is considered to be a requirement of any true object-oriented programming language (OOPL).
  13. 13. Example Public class shape { int calculateArea(int width,int height) { return width*height; } float calculateArea(int radius) { return(22/7)*radius*radius; } } public class example { Public static void main(string args[]) { Shape sh=new shape(); System.out.println(sh.calculateArea(10)); } }
  14. 14. Inheritance  In object-oriented programming, inheritance is the concept that when a class of objects is define, any subclass that is defined can inherit the definitions of one or more general classes.  This means for the programmer that an object in a subclass need not carry its own definition of data and methods that are generic to the class (or classes) of which it is a part.  This not only speeds up program development; it also ensures an inherent validity to the defined subclass object
  15. 15. Example Public class shape { protected int width; protected int height; Int calculateArea() { Return x*y; } Public class dimensionshape extends shape { Private int depth; Int calculateVolume() { Return width*height*depth; } }
  16. 16. End
  17. 17. If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  18. 18. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com IKK Road, East Hill, Kozhikode Kerala, India. Ph: + 91 – 495 30 63 624 NIT-TBI, NIT Campus, Kozhikode, Kerala, India.