Objects as a programming concept

Slides:



Advertisements
Similar presentations
Final and Abstract Classes
Advertisements

ITEC200 – Week03 Inheritance and Class Hierarchies.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
Starting Classes and Methods. Objects have behaviors In old style programming, you had: –data, which was completely passive –functions, which could manipulate.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
Chapter 10 Classes Continued
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
Inheritance using Java
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
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.
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
CSC 142 Computer Science II Zhen Jiang West Chester University
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
8. Inheritance “Is-a” Relationship. Topics Creating Subclasses Overriding Methods Class Hierarchies Abstract Class Inheritance and GUIs The Timer Class.
Classes. Constructor A constructor is a special method whose purpose is to construct and initialize objects. Constructor name must be the same as the.
Object Oriented Programming
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Inheritance and Polymorphism. Superclass and Subclass Inheritance defines a relationship between objects that share characteristics. It is a mechanism.
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
COMPUTER SCIENCE & TECHNOLOGY DEGREE PROGRAMME FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UVA WELLASSA ‏ Properties of Object Oriented Programming.
BY:- TOPS Technologies
JAVA ACCESS MODIFIERS. Access Modifiers Access modifiers control which classes may use a feature. A classes features are: - The class itself - Its member.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Inheritance a subclass extends the functionality of a superclass a subclass inherits all the functionality of a superclass don't reinvent the wheel – "stand.
Java Programming Fifth Edition Chapter 9 Introduction to Inheritance.
Computer Programming II Lecture 5. Introduction to Object Oriented Programming (OOP) - There are two common programming methods : procedural programming.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Introduction to Object-oriented Programming
Advanced Programming in Java
Modern Programming Tools And Techniques-I
Abstract classes and interfaces
OOP: Encapsulation &Abstraction
Objects as a programming concept
Classes (Part 1) Lecture 3
Final and Abstract Classes
Objects as a programming concept
Data Structures and Algorithms
Chapter 3: Using Methods, Classes, and Objects
PHP Classes and Objects
Advanced Programming in Java
OOP’S Concepts in C#.Net
Abstract classes and interfaces
Classes & Objects: Examples
Advanced Programming Behnam Hatami Fall 2017.
Advanced Java Programming
Java Programming, Second Edition
Java Inheritance.
Chapter 9 Carrano Chapter 10 Small Java
Object-Oriented Programming
Inheritance and Polymorphism
Abstract classes and interfaces
Object Oriented Programming
Final and Abstract Classes
Chapter 11 Inheritance and Encapsulation and Polymorphism
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
Classes and Methods 15-Aug-19.
C++ Object Oriented 1.
CSG2H3 Object Oriented Programming
Presentation transcript:

Objects as a programming concept IB Computer Science

HL Topics 1-7, D1-4 1: System design 2: Computer Organisation 3: Networks 4: Computational thinking 5: Abstract data structures 6: Resource management 7: Control D: OOP

HL & SL D.3 Overview 1: System design 2: Computer Organisation 3: Networks D.3 Program development D.3.1 Define the terms: class, identifier, primitive, instance variable, parameter variable, local variable D.3.2 Define the terms: method, accessor, mutator, constructor, signature, return value D.3.3 Define the terms: private, protected, public, extends, static D.3.4 Describe the uses of the primitive data types and the reference class string D.3.5 Construct code to implement assessment statements D.3.6 Construct code examples related to selection statements D.3.7 Construct code examples related to repetition statements D.3.8 Construct code examples related to static arrays D.3.9 Discuss the features of modern programming languages that enable internationalization D.3.10 Discuss the ethical and moral obligations of programmers 4: Computational thinking 5: Abstract data structures 6: Resource management 7: Control D: OOP

Topic D.3.3 Define the terms: private, protected, public, extends, static

private The private modifier specifies that the member can only be accessed in its own class. class Student { private String name; public String getName() return name; }

protected protected modifier specifies that the member can only be accessed within its own class/package (as with private) and, in addition, by a subclass. class Student { protected String name; public String getName() return name; }

public A class may be declared with the modifier public, in which case that object/variable is visible to all classes everywhere class Student { private String name; public String getName() return name; }

Summary of modifiers Modifier Class Package Subclass World public Y protected N no modifier private The first data column indicates whether the class itself has access to the member defined by the access level - a class always has access to its own members. The second column indicates whether classes in the same package as the class have access to the member. The third column indicates whether subclasses of the class declared outside this package have access to the member. The fourth column indicates whether all classes have access to the member.

Inheritance Inheritance can be defined as the process where one object acquires the properties of another. With the use of inheritance the information is made manageable in a hierarchical order. When we talk about inheritance, the most commonly used keyword would be extends and implements. These words would determine whether one object IS-A type of another. By using these keywords we can make one object acquire the properties of another object.

extends IS-A is a way of saying : This object is a type of that object. Let us see how the extends keyword is used to achieve inheritance. public } class Animal{ Mammal extends Animal{ Reptile extends Animal{ Dog extends Mammal{

This means… Now, based on the example, In Object Oriented terms, the following are true: Animal is the superclass of Mammal class. Animal is the superclass of Reptile class. Mammal and Reptile are subclasses of Animal class. Dog is the subclass of both Mammal and Animal classes. Now, if we consider the IS-A relationship, we can say: Mammal IS-A Animal Reptile IS-A Animal Dog IS-A Mammal Hence : Dog IS-A Animal as well With use of the extends keyword the subclasses will be able to inherit all the properties of the superclass except for the private properties of the superclass.

static Declares a static member of a class that will be the same for all members. The static keyword in Java means that the variable or function is shared between all instances of that class as it belongs to the type, not the actual objects themselves. So if you have a variable: private static int i = 0; and you increment it ( i++ ) in one instance, the change will be reflected in all instances. Also see: http://www.javatpoint.com/static-keyword-in-java