15
Object Oriented Programming Lecture # 1,2

Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

Object Oriented Programming

Lecture # 1,2

Page 2: Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

Contents

Programming Languages, Compilers, and Interpreters

Object-oriented programming

History of Java

Java’s Bytecode

Compiling and Running Java Program

Why use Java?

Page 3: Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

Programming Languages, compilers and Interpreters

Machine Language

Assembly Language

Compiler:

“Compilers translate source code into object code”

Interpreter

Page 4: Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

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.

Page 5: Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

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.

Page 6: Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

OOP Principles

The Three OOP Principles

1. Encapsulation

Page 7: Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

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.

Page 8: Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

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.

Page 9: Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

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.

Page 10: Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

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.

Page 11: Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

Compiling and Running a Java Program

Page 12: Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

Execution Model of JAVA

Page 13: Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

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.

Page 14: Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

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.

Page 15: Object Oriented Programming - WordPress.com · 2019. 4. 9. · Object-oriented Supports object-orientation Robust manages memory allocation and de-allocation for you provides object-oriented

Thank You!