Object Oriented Programming. Budditha Hettige Department of Computer Science

Similar documents
Java Interview Questions and Answers

CSCI 253. Object Oriented Programming (OOP) Overview. George Blankenship 1. Object Oriented Design: Java Review OOP George Blankenship.

History OOP languages Year Language 1967 Simula Smalltalk

Chapter 1 Fundamentals of Java Programming

Fundamentals of Java Programming

CEC225 COURSE COMPACT

SE 360 Advances in Software Development Object Oriented Development in Java. Polymorphism. Dr. Senem Kumova Metin

Java (12 Weeks) Introduction to Java Programming Language

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

Android Application Development Course Program

PHP Object Oriented Classes and objects

How To Design Software

Part I. Multiple Choice Questions (2 points each):

C++ INTERVIEW QUESTIONS

Chapter 13 - Inheritance

CS1002: COMPUTER SCIENCE OO MODELLING & DESIGN: WEEK 5

Java SE 8 Programming

Java SE 7 Programming

Java SE 7 Programming

3 Pillars of Object-oriented Programming. Industrial Programming Systems Programming & Scripting. Extending the Example.

The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0

Compiling Object Oriented Languages. What is an Object-Oriented Programming Language? Implementation: Dynamic Binding

Java SE 7 Programming

Introduction to Programming Block Tutorial C/C++

CS193j, Stanford Handout #10 OOP 3

Java Programming Language

AP Computer Science Java Subset

Java Application Developer Certificate Program Competencies

Japan Communication India Skill Development Center

How To Write A Program In Java (Programming) On A Microsoft Macbook Or Ipad (For Pc) Or Ipa (For Mac) (For Microsoft) (Programmer) (Or Mac) Or Macbook (For

D06 PROGRAMMING with JAVA

Pemrograman Dasar. Basic Elements Of Java

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

Cohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT - BCNS/05/FT - BIS/06/FT - BIS/05/FT - BSE/05/FT - BSE/04/PT-BSE/06/FT

Course Number: IAC-SOFT-WDAD Web Design and Application Development

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75

El Dorado Union High School District Educational Services

Object Oriented Software Design II

Chapter 6: Programming Languages

DIPLOMADO DE JAVA - OCA

Java EE Web Development Course Program

WORKSPACE WEB DEVELOPMENT & OUTSOURCING TRAINING CENTER

Polymorphism. Problems with switch statement. Solution - use virtual functions (polymorphism) Polymorphism

COMMUNITY COLLEGE OF CITY UNIVERSITY CITY UNIVERSITY OF HONG KONG

a. Inheritance b. Abstraction 1. Explain the following OOPS concepts with an example

Syllabus for CS 134 Java Programming

An Incomplete C++ Primer. University of Wyoming MA 5310

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

Java How to Program, 5/e Test Item File 1 of 5

CompuScholar, Inc. Alignment to Utah's Computer Programming II Standards

Course MS10975A Introduction to Programming. Length: 5 Days

CS 111 Classes I 1. Software Organization View to this point:

Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer

ATM Case Study OBJECTIVES Pearson Education, Inc. All rights reserved Pearson Education, Inc. All rights reserved.

Glossary of Object Oriented Terms

Testing Tools Content (Manual with Selenium) Levels of Testing

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Japan Communication India Skill Development Center

Japan Communication India Skill Development Center

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Object-Oriented Programming in Java

Compile-time type versus run-time type. Consider the parameter to this function:

Chapter 5 Aspect Oriented Programming

The Interface Concept

Computing Concepts with Java Essentials

Description of Class Mutation Mutation Operators for Java

CIS 190: C/C++ Programming. Polymorphism

William Paterson University of New Jersey Department of Computer Science College of Science and Health Course Outline

Computer Information Systems (CIS)

Aspect-Oriented Programming

Programmation 2. Introduction à la programmation Java

Japan Communication India Skill Development Center

Tutorial on Writing Modular Programs in Scala

Object-Oriented Programming: Polymorphism

Java Programming. Binnur Kurt Istanbul Technical University Computer Engineering Department. Java Programming. Version 0.0.

Polymorphism. Why use polymorphism Upcast revisited (and downcast) Static and dynamic type Dynamic binding. Polymorphism.

BCS Higher Education Qualifications. Professional Graduate Diploma in IT. Programming Paradigms Syllabus

Course Name: ADVANCE COURSE IN SOFTWARE DEVELOPMENT (Specialization:.Net Technologies)

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

Java CPD (I) Frans Coenen Department of Computer Science

Web Development in Java

Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is

Agile Software Development

How To Teach C++ Data Structure Programming

Advanced OOP Concepts in Java

Copyright. Restricted Rights Legend. Trademarks or Service Marks. Copyright 2003 BEA Systems, Inc. All Rights Reserved.

Hoare-Style Monitors for Java

Server-Side Scripting and Web Development. By Susan L. Miertschin

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

Lecture 1 Introduction to Android

Specialized Programme on Web Application Development using Open Source Tools

ICOM 4015: Advanced Programming

The Clean programming language. Group 25, Jingui Li, Daren Tuzi

Overview. Elements of Programming Languages. Advanced constructs. Motivating inner class example

Lecture 7 Notes: Object-Oriented Programming (OOP) and Inheritance

JavaCard. Java Card - old vs new

TOWARDS A GREEN PROGRAMMING PARADIGM FOR MOBILE SOFTWARE DEVELOPMENT

Some Scanner Class Methods

Transcription:

Object Oriented Programming Budditha Hettige Department of Computer Science

Overview Introduction to OOP Class and Objects Constructors Encapsulation Composition Inheritance Polymorphism Interfaces Packages Exception handling File Handling GUI Programming OOP Software development 7/11/2015 Budditha Hettige (budditha@yahoo.com) 2

Introduction (OOP) OOP is a programming paradigm that represents concepts as "objects" that have data fields (attributes that describe the object) and associated procedures known as methods 3

Advantages of OOP Provides a clear modular structure for programs OOP makes it easy to maintain and modify existing code (new objects can be created with small differences to existing ones) OOP provides a good framework for code libraries Software components can be easily adapted and modified by the programmer. 4

Modular Structure School 5

Exercise Identify suitable state and behaviors (Attributes and methods) for the following Student Bank Account Book Employee Sales Summary Course Result 7/11/2015 Budditha Hettige (budditha@yahoo.com) 6

Concepts of OOP Objects Classes Encapsulation Inheritance Polymorphism Data Abstraction 7

What is an Objects? Object is a software bundle of related state and behavior Characteristics: state and behavior 8

What is a class? A Java class is a group of Java methods and variables Object is an instance of a class Example class Person { // Methods // Variables } 9

Example Create a Java Class Account with suitable methods and variables 7/11/2015 Budditha Hettige (budditha@yahoo.com) 10

Class Modifiers Public Abstract Final Default (none) 11

Class Modifiers public: anyone can create an object of the defined class. only one public class per file, must have same name as the file (this is how Java finds it!). default: is non-public (if you don't specify "public"). Java Programming: OOP 12

Class Modifiers abstract: modifier means that the class can be used as a superclass only. no objects of this class can be created. final: if its definition is complete and no subclasses are desired or required a final class never has any subclasses, the methods of a final class are never overridden Java Programming: OOP 13

Field Modifiers public protected private none or package or default Static Final 14

Field Modifiers public: any method (in any class) can access the field. protected: any method in the same package can access the field, or any derived class. private: only methods in the class can access the field. Default: is that only methods in the same package can access the field. Java Programming: OOP 15

Field Modifiers Static: Fields declared static are called class fields (class variables). others are called instance fields. There is only one copy of a static field, no matter how many objects are created. Final:class and instance variables (static and nonstatic fields) may be declared final. The keyword final means: once the value is set, it can never be changed static final int BUFSIZE=100; final double PI=3.14159; Java Programming: OOP 16

Method Modifiers public protected none or package or default private final abstract static native synchronized 17

Method Modifiers private/protected/public: same idea as with fields. abstract: no implementation given, must be supplied by subclass. the class itself must also be declared abstract Java Programming: OOP 18

Method Modifiers static: the method is a class method, it doesn't depend on any instance fields or methods, and can be called without first creating an object. final: the method cannot be changed by a subclass (no alternative implementation can be provided by a subclass). Java Programming: OOP 19

Method Modifiers native: the method is written in some local code (C/C++) - the implementation is not provided in Java. synchronized: only one thread at a time can call the method. Java Programming: OOP 20

Method Overloading You can overload methods: same method name, different parameters. you can't just change return type, the parameters need to be different. Method overloading is resolved at compile time. int CounterValue() { } return counter; Won't Work! double CounterValue() { return (double) counter; } Java Programming: OOP 21

All Possible Combinations of Features and Modifiers Modifier Class Variable Method public yes yes yes protected no yes yes None (default) yes yes yes private no yes yes final yes yes yes abstract yes no yes static no yes yes native no no yes transient no yes no volatile no yes no synchronized no no yes strictfp yes no yes 22

Example Create a class Student with following methods print(); input() Create a class Length with following methods Print() input() Add(Lenth1, Length2) 23

Example contd. Create a class Name with 3 attribute (First name, middle name and last name) and include following methods Print(); input() Create a class name Date with 3 attribute (Day, Month and year) and include following methods print() Input() printformat1() // 23.5.2015 PrintFormat2() // 23 rd May 2015 24