+ All Categories
Home > Engineering > 130704798265658191

130704798265658191

Date post: 09-Aug-2015
Category:
Upload: tanzeel-ahmad
View: 45 times
Download: 0 times
Share this document with a friend
Popular Tags:
27
First day handout Introductory Session 1
Transcript

1

First day handoutIntroductory Session

2

Course Title Object Oriented Programming Class Schedule

Mon:0945-1115hrWed: 0945-1115hr Thur: 1130-1300hrFri:0800-0930hr

Location Office Timings

Tue 1500– 1630 Feel free to discuss any query related to the course work

with in the campus time for any length (prior information is requested)

3

The Book

Text book: Introduction to Java Programming by Y.Deniel

Liang, 7th edition Reference:Java, How to Program 9th by Deitel & Deitel, 9th

edition.

4

Things to Do?Be punctual and regular in classes

80% attendance is mandatory Be ready to discuss

Logical and methodical Be polite, to the point and respect others point of

view Must Attend all Quizzes

Five quizzes, unannounced, no make-up, no drop, no best of …..

Assignment - Take home, Lab Tasks, Theoretical Originality, on-time, ethical Four Assignments in single or Team (4x members)

Reading Stuff & Practice:Be ready to discuss the assigned tasks when asked

5

Things to Do?Be punctual and regular

in classes80% attendance is

mandatory Be ready to discuss

Logical and methodical Be polite, to the point

and respect others point of view

Be on timeFollow all the morals

and ethics of classroomNo mobile phones in

the classStudent cards must be

hanging

Must Attend all QuizzesFive quizzes,

unannounced, no make-up, no drop, no best of …..

Assignment - Take home, Lab Tasks, Theoretical Originality, on-time, ethical Four Assignments in

Team (4-5x members)Reading Stuff &

PracticeBe ready to discuss

the assigned chapters when asked

6

Grading Unannounced Quizzes (5 x 3% =

15%)Presentation (5%)

Not presenting = 0Assignments (Timely submission) (4 x 2.5% =

10%)Sessional I (10%)Sessional II (15%)Final Exam ( 45- 50%)

7

Presentation Individual / group Presentations:

Each group must give Assignment presentation in class.

Students are required to speak without notes, although visual aids may be used.

Presentations will be graded subjectively both on the quality of the content and the effectiveness of the communication.

The grades will be as:Style, communication and interpersonal skill - 1.5Clarity of thoughts/ understanding -

1.5Q&A 2Total 5

8

Assignment Four assignments (Team work)

Timely submission, originality and ethicalGroup of four

All Homework assignments are due at 1700 hrs sharp on the date specified. Timely submission on Hard + soft copy full credit Late submission will be given a maximum of half credit

and accepted only within two days of the after the due date.

Assignment # 1 – Due on 22 FebAssignment # 2 – Due on 14 MarAssignment # 3 – Due on 18 AprAssignment # 4 – Due on 16 May

Description of assignments will be uploaded shortly

9

Reading and discussion Reading assignments

Reading material will be provided regularly during the course

Read, understand and be ready to discuss in the class

Seminar/Tutorials will be conducted Total grade points 5

Satisfactory 0.5Good 1.5Very Good 1.5Excellent 1.5

10

Quizzes Unannounced

Element of surpriseFive quizzes of 10-15 min durationClose book, notes, discussion etcNo makeup quiz, no best of, class average etcNo fixed frequency Total 10 grade points

OOP introduction Object means a real word entity such as pen, chair, table etc. Object-Oriented Programming is a methodology to design a

program using classes and objects.

Characteristics

The most important features of object-oriented programming are:

Object Class Inheritance Polymorphism Abstraction Encapsulation

Objects Any entity that has state and behavior is known as an object. For

example: chair, pen, table, keyboard, bike etc. It can be physical and logical.

In the OOP approach, data and the functions are packed together into one box known as an object

Objects of the program interact by sending messages to each other

Class Collection of objects is called class. It is a logical entity.

Inheritance Inheritance is Ability to create one object from another. When one object acquires all the properties and behaviors of

parent object that is known as inheritance. It provides code reusability.

This feature allows developers to define objects in a hierarchy much like a taxonomy chart

Each level of the hierarchy defines a more specific object than the parent level

Each level inherits all the properties and methods of it's parent object and at that point you define the more specific properties and methods need by the new level of object you created

Polymorphism When one task is performed by different ways i.e. known as

polymorphism. For example: to draw something e.g. shape or rectangle etc.

In java, we use method overloading and method overriding to achieve polymorphism.

Suppose you have a Shape object that has a Draw method Then you could define a Circle, Square and Triangle object

as Shape objects and override the Draw method to draw specifically a Circle, Square or Triangle method respectively

All 4 objects would then have a Draw method but only the right method for the right object would be called.

Abstraction Hiding internal details and showing functionality is known as

abstraction. For example: phone call, we don't know the internal processing.

In java, we use abstract class and interface to achieve abstraction.

Encapsulation Binding (or wrapping) code and data together into a single unit is

known as encapsulation. Both the data, and the functionality that could affect or display

that data are included under a unified name (the object name itself).

In the classic definition, the data elements (or properties of the object) are not available to the outside world directly.

Instead, methods would be created to give access to these values outside of the object

Now we have the ability to declare properties as being public or private

BenefitsCode Reuse and Recycling Objects made in a program can be reused by any other program

This increases the reusability of the programs once written.Encapsulation Once an Object is created, knowledge of its implementation is not

necessary for its use. In older programs, coders needed to understand the details of a piece of code before using it

Objects have the ability to hide certain parts of themselves from programmers. This prevents programmers from tampering with values they shouldn't. Additionally, the object controls how one interacts with it, preventing other kinds of errors. For example, a programmer cannot set the width of a window to -400

Easy to maintain and modify It is easy to maintain and modify existing code as new objects can

be created with small differences to existing ones.Easy to upgradeThe programs written in an OOP can be easily updated by using the

facilities of inheritance.

OOP vs. Procedure/function Oriented programming OOPs makes development and maintenance easier where as in

Procedure-oriented programming language it is not easy to manage if code grows as project size grows.

OOPs provides data hiding whereas in Procedure-oriented programming language a global data can be accessed from anywhere.

OOPs provides ability to simulate real-world event much more effectively. We can provide the solution of real word problem if we are using the Object-Oriented Programming language.

Oop vs pop(cont..)Procedure Oriented Programming Object Oriented Programming

Divided Into Here, program is divided into small parts called functions.

In OOP, program is divided into parts called objects.

Importance Here,Importance is not given to data but to functions as well as sequence of actions to be done.

In OOP, Importance is given to the data rather than procedures or functions because it works as a real world.

Data Access Most function uses Global data for sharing that can be accessed freely from function to function in the system.

In OOP, data can not move easily from function to function, It can be kept public or private so we can control the access of data.

Access Specifiers It does not have any access specifier.

OOP has access specifiers named Public, Private, Protected, etc.

Data Moving Data can move freely from function to function in the system.

In OOP, objects can move and communicate with each other through member functions.

Data Hiding It does not have any proper way for hiding data so it is less secure.

OOP provides Data Hiding so provides more security.

Examples Example of POP are : C, VB, FORTRAN, Pascal.

Example of OOP are : C++, JAVA, VB.NET, C#.NET.

Java introduction

Java is an object-oriented programming language developed by James Gosling and colleagues at Sun Microsystems in the early 1990s

Java is: Object Oriented: In Java, everything is an Object. Java can be

easily extended since it is based on the Object model. Platform independent: Unlike many other programming

languages including C and C++, when Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code.

Java is platform independent. This means that it will run on just about any operating system like Windows, Linux, Mac OS.

20

Simple: Java is designed to be easy to learn. If you understand the basic concept of OOP Java would be easy to master.

Automatic garbage collection:Automatic garbage collection is the process of looking

at heap memory, identifying which objects are in use and which are not, and deleting the unused objects.

In a programming language like C, allocating and deallocating memory is a manual process. In Java, process of deallocating memory is handled automatically by the garbage collector.

It usually runs when your application runs out of memory.

This garbage collector is under the control of JVM.

21

Java Is Robust : Robust means reliable. No programming

language can ensure complete reliability. Java puts a lot of emphasis on early checking for possible errors, because Java compilers can detect many problems that would first show up at execution time in other languages. Java has eliminated certain types of error-prone programming constructs found in other languages. It does not support pointers, for example, thereby eliminating the possibility of overwriting memory and corrupting data.

Java has a runtime exception-handling feature to provide programming support for robustness.

22

Java Is Multithreaded :Multithreading is a program’s capability to perform

several tasks simultaneously. For example, downloading a video file while playing the video would be considered multithreading.

Multithread programming is smoothly integrated in Java, whereas in other languages you have to call procedures specific to the operating system to enable multithreading.

Java Is Dynamic :Java was designed to adapt to an evolving environment.

New class can be loaded on the fly without recompilation. There is no need for developers to create, and for users to

install, major new software versions. New features can be

incorporated transparently as needed.

Compilation Process: Traditional Compilers In the traditional compilation process, the compiler produces

machine code for a specific family of processors For example, given a source program, a compiler for the x86

family of processors will produce binary files for this family of processors

A disadvantage of this compilation method is that the code produced in each case is not portable

To make the resulting code portable, we need the concept of a virtual machine

Java Compiler Compiler translates program to byte code The JVM is a byte code interpreter that translates byte code to machine

code

How things work in Java You write the actual code for your programme in a text editor. (In Net

Beans, there's a special area for you to write code.) The code is called source code, and is saved with the file extension .java.

A programme called Javac is then used to turn the source code into Java Byte Code. This is known as compiling. After Javac has finished compiling the Java Byte Code, it creates a new file with the extension .class. (At least, it does if no errors are detected.)

Once the class file has been created, it can be run on the Java Virtual Machine.

So:

Create source code with the extension .java Use Javac to create (compile) a file ending in .class Run the compiled class in JVM. NetBeans handles all the creating and compiling for you.

Compilation Process: Java Compilers

Java development kit

JDK (Java Development Kit) JDK contains tools needed to develop the Java programs, and JRE to run the programs The tools include compiler (javac.exe), Java application launcher (java.exe), Appletviewer, etc… Compiler converts java code into byte code. JRE (Java Runtime Environment) JRE contains JVM, class libraries, and other supporting files. It does not contain any

development tools such as compiler, debugger, etc. If you want to run any java program, you need to have JRE installed in the systemJVM (Java Virtual Machine) The JVM provides a platform-independent way of executing code but JVM itself is

not a platform independent as every system has its own JVM installed. Java Virtual Machine interprets the byte code into the machine code depending

upon the underlying operating system and hardware combination. It is responsible for all the things like garbage collection, array bounds checking, etc… JVM is platform dependent

27

THE END