Basic object oriented approach


Published on

The content is simple discussion about the Object Oriented technologies

Published in: Software, 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

Basic object oriented approach

  1. 1. Basic Object-Oriented Approach Jigar Jobanputra Jigar Jobanputra(JJ)
  2. 2. Session Objectives  Discuss the object oriented approach  Discuss the drawbacks of traditional programming  Discuss object oriented programming  Discuss basic Object-Oriented concepts such as objects, classes, properties, methods, abstraction, inheritance, encapsulation, reusability and polymorphism.  Describe Java Virtual Machine  Write the First Java Program Jigar Jobanputra(JJ)
  3. 3. The Object-Oriented Approach PersonnelAccounts Sales The real world around is full of objects .We can consider both the living beings as well as non living elements as objects. For example, the different departments in a company are objects. Jigar Jobanputra(JJ)
  4. 4. Drawbacks of Traditional Programming  Unmanageable programs  Problems in modification of data  Difficulty in implementation Jigar Jobanputra(JJ)
  5. 5. Object – Oriented Programming Data Employee details Salary statements Bills Vouchers Receipts Functions Calculate salary Pay salary Pay bills Tally accounts Transact with banks Here the application has to implement the entities as they are seen in real life and associate their actions and attributes with each other. Accounts Jigar Jobanputra(JJ)
  6. 6. Objects Some real-life entities :  Physical Objects  Vehicles in a traffic -monitoring application  Electrical components in a circuit design problem  Elements of the computer-user environment  Windows  Menus An object is an element with defined boundaries that is relevant to the problem we are dealing with Jigar Jobanputra(JJ)
  7. 7. Objects (contd…)  Collections of data  An inventory of machine parts  A personnel file  User defined data types  Time  Angles  Complex numbers Jigar Jobanputra(JJ)
  8. 8. Objects (contd…) Model : Ferrari Color : Red Year : 1995 Actions Start Stop Accelerate Jigar Jobanputra(JJ)
  9. 9. Classes A class is a group of objects that have the same properties, common behavior. Polygon objects Polygon class Properties Vertices Border color Fill color Methods Draw Erase Move Jigar Jobanputra(JJ)
  10. 10. Encapsulation Encapsulation is a process that allows selective hiding of properties and methods in a class. Not accessible from outside class Accessible from outside class Private Public Jigar Jobanputra(JJ)
  11. 11. Inheritance Inheritance is the property that allows the reuse of an existing class to build a new class Animals Jigar Jobanputra(JJ)
  12. 12. Abstraction Attributes Methods Class Data abstraction is a process of identifying properties and methods related much to a particular entity as relevant to the application Jigar Jobanputra(JJ)
  13. 13. Reusability Make sounds Eat and drink Hunt prey Mew Drink milk Hunt mice Roar Eat flesh Hunt big game Felines Jigar Jobanputra(JJ)
  14. 14. Polymorphism Subclasses Polymorphism allows same method to behave differently on different classes. Class : Shape Methods : Draw Move Initialize Jigar Jobanputra(JJ)
  15. 15. Object – Oriented Languages  C ++  Small Talk  Eiffel  CLOS  Java Jigar Jobanputra(JJ)
  16. 16. The Problem with High Level Language P R O B L E M Program Applications written for a particular platform will not work on another platform S O L U T I O N Interpreter Interpreter Interpreter Program To solve this problem, we make use of interpreters So the code for any application can be written only once, which can then be executed with the help of Interpreters created for different platformsJigar Jobanputra(JJ)
  17. 17. Java Language  Java is a language from SUN Microsystems.  Java uses an Interpreter to execute code so that it may run on different computers without any change to the source code.  Java Programs are platform independent. Hence the code written in Java can be executed on different platforms.  Java is a program mainly used for Web based applications because of its support to different platforms.  Java is purely an Object Oriented Programming language. Jigar Jobanputra(JJ)
  18. 18. Java Virtual Machine (JVM) Source Code Imaginary computer’s instruction set Compiler Target Machine Java Virtual Machine For each computer, there is a unique Java Virtual Machine Machine language code Byte Code Jigar Jobanputra(JJ)
  19. 19. Life Cycle of a Java Program Compiler Filename.class Byte Code Source Code User Code Java Virtual Machine Jigar Jobanputra(JJ)
  20. 20. Execution procedure by the JVM The Java Virtual Machine creates a runtime system internally that helps the execution of code by : Loading the “ . class ” files. Managing the memory. Performing Garbage collection. Jigar Jobanputra(JJ)
  21. 21. Java code and JVM  All java programs are written keeping in mind the Java VM.  The Java source code and the byte code is machine independent while JVM is machine dependant.  Different machines with different Operating system will require a JVM developed for that machine. Jigar Jobanputra(JJ)
  22. 22. First Program class HelloJava { public static void main( String args[]) { System.out.println(“Welcome to the world of Java”); } } Jigar Jobanputra(JJ)
  23. 23. First Program [Contd…] • Save the file as • Use the javac command to compile the file • Execute the bytecodes of HelloJava.class using the java command Jigar Jobanputra(JJ)
  24. 24. Thank You Jigar Jobanputra(JJ)