Thursday, March 3, 2016

Day 1 Object Oriented Programming

Object Oriented Programming is a programming method that combines:
a) Data
b) Instructions for processing that data
into a self-sufficient ‘object’ that can be used within a program or in other programs.

Advantage of Object Oriented Programming

a) Objects are modeled on real world entities.
b) This enables modeling complex systems of real world into manageable software solutions.

Programming techniques

a) Unstructured Programming (Assembly language programming)
b) Procedural Programming (Assembly language, C programming)
c) Object Oriented Programming (C++, Java, Smalltalk, C#, Objective C)
Unstructured Programming
This consists of just writing the sequence of commands or statements in the main program, which modifies the state maintained in Global Data. Example: Assembly Language programs.
Limitations of Unstructured Programming
a) The data is global and code operates on it
b) As the size of code increases, maintenance is a problem
c) Does not have independent data for processing
d) The concept of local variables did not exist
e) Reusability of code was not supported
Assembly Language: Similar to machine language, but provides names for numeric instructions present in the machine language, making it easy for the programmer.
Machine language is the language which a Central Processing Unit (CPU) of a computer understands and consists only of numbers.

2. Variables

Global Variables
a) The variables that are declared outside any function body.
b) These variables exist for the entire life-cycle of the program.
c) Global variables can be accessed from anywhere within the program.
Local Variables
a) The variables that are declared within a function body.
b) Their scope is limited to within the function body.
c) Local variables cannot be accessed outside the function body.

Object Oriented Programming

OOPs concepts, Object Class and instance
Object
Object:  is a bundle of related variables and functions (also known methods).
Objects share two characteristics: They have State and Behavior.
State: State is a well defined condition of an item. A state captures the relevant aspects of an object
Behavior: Behavior is the observable effects of an operation or event,
Examples:
eg 1:
Object: House
State: Current Location, Color, Area of House etc
Behavior: Close/Open main door.
eg 2:
Object: – Car
State: Color, Make
Behavior: Climb Uphill, Accelerate, SlowDown etc
Note: Everything a software object knows (State) and can do (Behavior) is represented by variables and methods (functions) in the object respectively.
Characteristics of Objects:
  1. Abstraction
  2. Encapsulation
  3. Message passing

Message passing

A single object by itself may not be very useful. An application contains many objects. One object interacts with another object by invoking methods (or functions) on that object. Through the interaction of objects, programmers achieve a higher order of functionality which has complex behavior.
One object invoking methods on another object is known as Message passing.
It is also referred to as Method Invocation.
OOPs concepts, Message passing

Class

A class is a prototype that defines the variables and the methods common to all objects of a certain kind. Member Functions operate upon the member variables of the class. An Object is created when a class in instantiated.
How to create an Object?
An object is created when a class is instantiated
Declaring an Object of class :
ClassName Objectname;
Object definition is done by calling the class constructor

  1. JAVA TRAINING IN KATHMANDU
  2. JAVA TRAINING IN LALITPUR

No comments:

Post a Comment