OBJECT-ORIENTED PROGRAMMING CONCEPTS (Review). What is an Object? What is an Object? Objects have states and behaviors. Example: A dog has states - color,

Slides:



Advertisements
Similar presentations
Computer Science Dept. Fall 2003 Object models Object models describe the system in terms of object classes An object class is an abstraction over a set.
Advertisements

BITS Pilani Avinash Gautam Department of Computer Science and Information Systems.
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
Inheritance, part 2: Subclassing COMP 401, Fall 2014 Lecture 8 9/11/2014.
Lab#1 (14/3/1431h) Introduction To java programming cs425
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Classes and Objects in Java. What Is an Object?. An object is a software bundle of related state and behavior. Software objects are often used to model.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
What is an object? Your dog, your desk, your television set, your bicycle. Real-world objects share two characteristics: They all have state and behavior;
EEC-681/781 Distributed Computing Systems Java Tutorial Wenbing Zhao Cleveland State University
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Object-oriented Programming Concepts
Problem Solving #3: JVM ICS Outline Review of Key Topics Review of Key Topics Problem 1 Problem 1 Problem 2 Problem 2 Problem 3 Problem 3 Problem.
Object Oriented Paradigm Programming Paradigms En Mohd Norafizal A.Aziz.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 Chapter 8 Objects and Classes. 2 Motivations After learning the preceding chapters, you are capable of solving many programming problems using selections,
Java Objects and Classes. 3-2 Object Oriented Programming  An OO program models the application as a world of interacting objects.  A typical Java program.
MIT AITI 2003 Lecture 7 Class and Object - Part I.
1 Pertemuan 6 Object Oriented Programming Matakuliah: T0053/Web Programming Tahun: 2006 Versi: 2.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
+ Java vs. Javascript Jessi Style. + Java Compiled Can stand on its own Written once, run anywhere Two-stage debugging Java is an Object Oriented Programming.
Java Implementation Software Construction Lecture 6.
A First Program Using C#
Object-Oriented Programming Concepts
Programming Languages and Paradigms Object-Oriented Programming.
Lecture 3 Casting Abstract Classes and Methods Interfaces.
Chapter 4 Objects and Classes.
About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized.
Object Oriented Programming Concepts Fatih University Ceng-104-A Introduction to Object Oriented Programming Harun Reşit Zafer This is a slide version.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 2 1 Java Inheritance.
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
Object Oriented Programming Concepts. Object ► An object is a software bundle of related state and behavior. ► Software objects are often used to model.
Programming in Java CSCI-2220 Object Oriented Programming.
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
JAVA Programming (Session 4) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
Creating a Java Application and Applet
CS 5JA Introduction to Java Pop Quiz Define/Explain encapsulation. In object-oriented programming, encapsulation refers to the grouping of data and the.
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
What Is a Package? A package is a namespace that organizes a set of related classes and interfaces. Conceptually you can think of packages as being similar.
A Java program consists of a set of class definitions, optionally grouped into packages. Each class encapsulates state and behavior appropriate to whatever.
By : Robert Apeldorn. What is OOP?  Object-oriented programming is a programming paradigm that uses “objects” to design applications and computer programs.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
JAVA Programming (Session 2) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Object and Classes อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 3.
Lecture 5:Interfaces and Abstract Classes Michael Hsu CSULA.
Introduction to Object-oriented Programming
What is an Object Objects are key to understanding object-oriented technology. An object can be considered a "thing" that can perform a set of related.
Objects as a programming concept
Objects as a programming concept
University of Central Florida COP 3330 Object Oriented Programming
Objects as a programming concept
Objects as a programming concept
University of Central Florida COP 3330 Object Oriented Programming
EEC 484 Computer Networks Java Tutorial #1 Wenbing Zhao
Unit-2 Objects and Classes
البرمجة الكينونية بلغة جافا 1294
Interface.
Interfaces.
Inheritance Inheritance is a fundamental Object Oriented concept
Chapter 14 Abstract Classes and Interfaces
Selenium WebDriver Web Test Tool Training
Interfaces,Packages and Threads
Presentation transcript:

OBJECT-ORIENTED PROGRAMMING CONCEPTS (Review)

What is an Object? What is an Object? Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors - wagging, barking, eating. An object is an instance of a class. If we consider a dog, then its state is - name, breed, color, and the behavior is - barking, wagging, running

What is a Class? What is a Class? A class can be defined as a template/blue print that describes the behaviors/states that object of its type. support. A class can contain any of the following variable types: Local variables: Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed when the method has completed. Local variables: Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed when the method has completed. Instance variables: Instance variables are variables within a class but outside any method. These variables are instantiated when the class is loaded. Instance variables can be accessed from inside any method, constructor or blocks of that particular class. Instance variables: Instance variables are variables within a class but outside any method. These variables are instantiated when the class is loaded. Instance variables can be accessed from inside any method, constructor or blocks of that particular class. Class variables: Class variables are variables declared with in a class, outside any method, with the static keyword. Class variables: Class variables are variables declared with in a class, outside any method, with the static keyword.

What is Inheritance? What is Inheritance? Object-oriented programming allows classes to inherit commonly used state and behavior from other classes. Different kinds of objects often have a certain amount in common with each other. Mountain bikes, road bikes, and tandem bikes, for example, all share the characteristics of bicycles (current speed, current pedal cadence, current gear). Yet each also defines additional features that make them different: tandem bicycles have two seats and two sets of handlebars; road bikes have drop handlebars; some mountain bikes have an additional chain ring, giving them a lower gear ratio Bicycle now becomes the superclass of MountainBike, RoadBike, and TandemBike. In the Java programming language, each class is allowed to have one direct superclass, and each superclass has the potential for an unlimited number of subclasses

When we talk about inheritance, the most commonly used keyword would be extends and implements The syntax for creating a subclass is simple. At the beginning of your class declaration, use the extends keyword, followed by the name of the class to inherit from: class MountainBike extends Bicycle { class MountainBike extends Bicycle { // new fields and methods defining // new fields and methods defining // a mountain bike would go here // a mountain bike would go here }

The implements keyword is used by classes by inherit from interfaces. Interfaces can never be extended by the classes. public interface Animal { } public class Mammal implements Animal{ public class Mammal implements Animal{}

What Is an Interface? What Is an Interface? An interface is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface. An interface is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface. An interface is not a class. Writing an interface is similar to writing a class, but they are two different concepts. A class describes the attributes and behaviors of an object. An interface contains behaviors that a class implements. interface Bicycle { // wheel revolutions per minute // wheel revolutions per minute void changeCadence(int newValue); void changeCadence(int newValue); void changeGear(int newValue); void changeGear(int newValue); void speedUp(int increment); void speedUp(int increment); void applyBrakes(int decrement); void applyBrakes(int decrement); }

What Is a Package? What Is a Package? A package is a namespace that organizes a set of related classes and interfaces Conceptually you can think of packages as being similar to different folders on your computer You might keep HTML pages in one folder, images in another, and scripts or applications in yet another Keep things organized by placing related classes and interfaces into packages

The Java platform provides an enormous class library (a set of packages) suitable for use in your own applications. This library is known as the "Application Programming Interface", or "API" for short. Its packages represent the tasks most commonly associated with general-purpose programming. This library is known as the "Application Programming Interface", or "API" for short. Its packages represent the tasks most commonly associated with general-purpose programming.

For example, a String object contains state and behavior for character strings; a File object allows a programmer to easily create, delete, inspect, compare, or modify a file on the filesystem; a Socket object allows for the creation and use of network sockets; various GUI objects control buttons and checkboxes and anything else related to graphical user interfaces. package insurance; public class Policy{ public class Policy{ //Code goes here }

RESOURCES ndex.html