eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
Resources
 ::   Tutorials
 ::   Presentations
Perl & CGI tutorials
 ::   Intro to Perl/CGI and HTML Forms
 ::   Intro to Windows Perl
 ::   Intro to Perl 5
 ::   Intro to Perl
 ::   Intro to Perl Taint mode
 ::   Sherlock Holmes and the Case of the Broken CGI Script
 ::   Writing COM Components in Perl

Java tutorials
 ::   Intro to Java
 ::   Cross Browser Java

Misc technical tutorials
 ::   Intro to The Web Application Development Environment
 ::   Introduction to XML
 ::   Intro to Web Design
 ::   Intro to Web Security
 ::   Databases for Web Developers
 ::   UNIX for Web Developers
 ::   Intro to Adobe Photoshop
 ::   Web Programming 101
 ::   Introduction to Microsoft DNA

Misc non-technical tutorials
 ::   Misc Technopreneurship Docs
 ::   What is a Webmaster?
 ::   What is the open source business model?
 ::   Technical writing
 ::   Small and mid-sized businesses on the Web

Offsite tutorials
 ::   ISAPI Perl Primer
 ::   Serving up web server basics
 ::   Introduction to Java (Parts 1 and 2) in Slovak

 

Introduction to Web Programming
Object Orientation in Java  

  • Okay, so now that we understand the most basic Java syntax it is time to learn how object-oriented design is implemented in Java.

Java Classes

  • The basic unit of object-orientation in Java is the class. The class is often described as a blueprint for an object. It allows a programmer to define all of the properties and methods that internally define an object, all of the API methods that externally define an object, and all of the syntax necessary for handling encapsulation, inheritance and polymorphism.

  • When a virtual machine needs to create an actual object from the class' blueprint, it is said to createan "instance" (or instantiate) of the class. Thus, theblueprint is used to actualy create an object which isstored in the computer's memory. The object will actuallybe able to utilize the methods and fields defined by its class.

Many people use the following metaphorsto describe the relationship between a class and an object:You can think of a class as a cookie cutter and an instance as anactual cookie. Similarly, you can think of a class as ablueprint of a house and an instance as an actual house.

  • It is also important to know that more than one instance can be fabricated from the same classduring the execution of a program. What's more, each of theseinstances has its own copy of methods and fields so that overthe life of the program each can grow independently.

  • Thus,for example, a Buton class might be used to instantiate twobuttons in a program. Once instantiated, each Button has its own "Label" field and its own Background Color field. Duringthe program, one button might be set to be Blue and to say"Hello Cyberspace". Another might be set to red and "HelloSelena." Both remain Button objects, but they gain unique features.

    You can compare two objects to see if theyare built from the same class by using the "instanceof" keywordsucgh as in the following example:

    if (someObject instanceOf Button) { ...do something.... }

Previous Page |Next Page