Presentation is loading. Please wait.

Presentation is loading. Please wait.

Interfaces, Classes & Objects

Similar presentations


Presentation on theme: "Interfaces, Classes & Objects"— Presentation transcript:

1 Interfaces, Classes & Objects
13 Interfaces, Classes & Objects

2 Previously Class Libraries Packages Using Core Java Classes Process
Packages Views Javadoc Output – HTML View

3 Overview Classes Objects Instances Variables Methods Interfaces
Principles of Object Orientation

4 Classes and OO Programming
An OO program consists of at least one (usually many more) inter-dependent classes. A class is a user-defined data type that describes the properties and capabilities of the real-world objects with which the program has to deal. A class is a generic type of “thing”, whereas a specific “thing” (an instance of the class) is an Object. A class definition consists of both the properties (i.e. data) and the capabilities (i.e. program code) of that class.

5 An Analogy Consider the class Pen i.e. pens in general, not any one pen in particular. Properties (variables) Colour Thickness Type of Ink Capabilities (methods) Remove lid Draw line Draw circle Replace lid

6 An Analogy - Objects Instances of class Pen i.e. specific pens, belonging to specific people. Adam’s boardwriter Adam’s biro Amadeo’s pen Instances of the class Pen are called Objects.

7 Using Classes Definition Instantiation Declaration of variables
Instance variables - specific to one instance of a class Class variables - shared by all instances of that class Definition of methods A method is the program code required to perform a specific task with the class. Methods consist of statements. Instantiation Usually an instance of a class needs to be created before it can be used. Some classes (especially utility classes) have methods and variables that can be used without instantiation.

8 Interfaces Interfaces allow you to declare the structure of a class
They declare the variables and methods available To create an instance of an interface you would implement it

9 The Purpose of OO Programming
Classes should model the real world - thus leading to efficient coding. Classes are reusable. Libraries of reusable classes (“class libraries”) make sophisticated functionality easily available. This is a “construction kit” approach to programming. For example - consider graphical programs: Window class Text box Button class


Download ppt "Interfaces, Classes & Objects"

Similar presentations


Ads by Google