Escolar Documentos
Profissional Documentos
Cultura Documentos
BITS Pilani
Hyderabad Campus
BITS Pilani
Hyderabad Campus
Todays Agenda
Object Oriented paradigm Object Oriented concepts Basic terminology of Object Oriented principles
Functional Paradigm
We think in terms of functions acting on data
ABSTRACTION: Think of the problem in terms of a process that solves it. DECOMPOSITION: Break your processing down into smaller manageable processing units (functions). ORGANIZATION: Set up your functions so that they call each other (function calls, arguments, etc.)
FIRST: define your set of data structures (types, etc.) THEN: define your set of functions acting upon the data structures.
Objects
The world is made up of real world objects e.g. students, dogs, cars, cats, books.
Example:
Consider a system managing university students. A student object has: State id, name, age, contact number, address, stage, completed courses, current courses, faculty, Behavior enroll in a new course, change contact number, change enrolment, choose degree,
Basic Terminology
Abstraction is the representation of the essential features of an object. These are encapsulated into an abstract data type. Encapsulation is the practice of including in an object everything it needs hidden from other objects. The internal state is usually not accessible by other objects.
E.g. the message displayDetails() of the Person class should give different results when send to a Student object (e.g. the enrolment number).
Polymorphism
Poly means many and morph means forms. In Java we have two types of polymorphisms Compile-Time [ Method Overloading] Run-Time [ Method Overriding]
Polymorphism
An object has multiple identities, based on its class inheritance tree It can be used in different ways
Package Statement
First Program
public class HelloWorld { public static void main(String args[]) { System.out.println("Hello World"); } }
HelloWorld.java
source code
javac HelloWorld.java
compile
java HelloWorld
HelloWorld.class
bytecode
run
The VM starts executing the users class by running its main() method.
Machine Code
CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus
Conclusions
Class is a collection of objects. Every object has state, behavior and identity.