Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Java. Java  An Object-Oriented, platform-neutral, secure language.  Object Oriented – software development method – a program is thought.

Similar presentations


Presentation on theme: "Introduction to Java. Java  An Object-Oriented, platform-neutral, secure language.  Object Oriented – software development method – a program is thought."— Presentation transcript:

1 Introduction to Java

2 Java  An Object-Oriented, platform-neutral, secure language.  Object Oriented – software development method – a program is thought of as a group of objects that work together.  Objects are created from templates called classes  Platform neutrality – a program’s ability to run without modification in different computing environments.  As long as a platform has a java virtual machine, it can run the code.  Java has automatic memory management, making it secure.

3 Object-oriented v. Procedural Programming  In this class, in addition to learning the java language, you will learn object- oriented programming.  The two go together;  Object-oriented – an approach to building programs that mimic how objects are assembled in the physical world.  We will give some examples initially, then move to some basic programming concepts, and at the end of the class revisit the creation of objects.

4 Procedural v. Object-Oriented  Procedural – instructions carried out step-by-step. Example – BASIC language.  Object-oriented looks at a program from a different angle, focusing on the task the program was created to perform.  Concept – a set of objects that work together to accomplish a task.  Each object is a part, interacting with the others in a controlled way.  Real World Example – Stereo System – many objects hooked together  Speaker components play mid-range and high-frequency  Subwoofer plays low bass  Tuner – radio signals  CD or MP3 player  Turntable – vinyl’s coming back!  Designed to interact using standard input and output connectors

5 Stereo Example  Object-oriented works under the same principle – you put together a program by creating new objects and then connecting them to each other and to existing objects.  These objects are combined in a standard way  Each object plays a specific role in the larger program.

6 Objects and Classes  Object = self-contained element of a computer program that represents a related group of features, designed to accomplish specific tasks.  Class – a template used to create an object  Every object created from the same class has similar features.  The process of creating an object from a class is called instantiation, which is why objects are called instances  Think back to Alice – when you put an object into a world, you instantiated an object.  Objects were in classes – people, school, environment, etc.

7 Example – Creating a class to represent command buttons  All buttons have attributes (Variables)  Have text displayed  Are a specific size  Have a specific appearance, 3D, shadow, etc.  Command buttons also have behaviors: (Methods)  Whether it requires a single- or a double-click  What it does when clicked  Whether it should ignore mouse clicks.  So, you would create a command button “CLASS”, and then make command button objects.

8 Organizing Classes and Class Behavior  Inheritance – allows one class to inherit behaviors and attributes of another class.  All classes are arranged in a hierarchy  A class can only have one superclass, unlimited subclasses  Designing an effective hierarchy requires planning  It allows you to reduce the number of repetitive features and redundant code.

9  Things the Class Knows – Instance Variables  Things the class does - Methods


Download ppt "Introduction to Java. Java  An Object-Oriented, platform-neutral, secure language.  Object Oriented – software development method – a program is thought."

Similar presentations


Ads by Google