Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports...
Transcript of Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports...
Object Oriented Programming
Lecture # 1,2
Contents
Programming Languages, Compilers, and Interpreters
Object-oriented programming
History of Java
Java’s Bytecode
Compiling and Running Java Program
Why use Java?
Programming Languages, compilers and Interpreters
Machine Language
Assembly Language
Compiler:
“Compilers translate source code into object code”
Interpreter
Object Oriented Programming
“A language that supports encapsulation (objects), message-passing (polymorphism), and inheritance, is object-oriented programming language.”
Abstraction
Hierarchical abstractions of complex systems can also be applied to computer programs.
Breaking them into more manageable pieces.
OOP Principles
The Three OOP Principles
1. Encapsulation
The mechanism that binds together code and the data it manipulates, and
keeps both safe from outside interference and misuse.
Wrapping up data member and method together into a single unit (i.e. Class) is called Encapsulation.
Encapsulation means hiding the internal details of an object, i.e., how an object does something.
Encapsulation is a technique used to protect the information in an object from the other object.
OOP Principles
The Three OOP Principles
1. Encapsulation
OOP Principles
The Three OOP Principles
2. Inheritance
Inheritance is the process by which one object acquires the properties of another object.
Inheritance is the process of object reusability.
OOP Principles
The Three OOP Principles
3. Polymorphism
Polymorphism means one name many forms.
One function behaves in different forms.
In other words, "Many forms of a single object is called Polymorphism."
Example
Person behaves like a SON in the house, at the same time that person behaves like an EMPLOYEE in office.
History of JAVA
Java was conceived by James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan at Sun Microsystems, Inc. in 1991.
Took 18 months to develop the first working version.
Initially called “OAK” and was renamed to “JAVA” in 1995.
Java Bytecode
Java compiler compiles your program into bytecode rather than machine language.
This bytecode is a machine language for the Virtual Machine.
For converting bytecode into native machine code, java virtual machine(JVM) is used.
The JVM is an Interpreter that translates and executes bytecode.
Bytecode promotes Portability.
Compiling and Running a Java Program
Execution Model of JAVA
Why use JAVA?
Simple:
Java was designed to be easy for the professional programmer to learn and use effectively.
Object-oriented
Supports object-orientation
Robust
manages memory allocation and de-allocation for you provides object-oriented exception handling.
Multithreaded
Java supports multithreaded programming, which allows you to write programs that do many things simultaneously.
Why use JAVA?
Architecture-neutral
Write once; run anywhere, any time, forever.
Interpreted and High performance
Intermediate representation called Java bytecode
Bytecode is easy to translate directly into native machine code for very high performance by using a just-in-time compiler.
Thank You!