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
Inheritance in Java  

  • Inheritance in Java is very simple and is handled by the "extends" keyword. As you might expect,subclasses work just like (inherit all of the functionality) their superclass except that they typically add extra funtionality.

    If a class does not specifically extendanything than it will be automaticaly extended from the root Object class

  • Thus, in the following example, wecreate a subclass of Applet caled myApplet:

    public class myApplet extends Applet
      {
      ...new fields and methods...
      }
    

  • Further, extension is transitive. Thatis if you extend from a class which is an extension of another, then you gain the functionality of your superclass as well as itssuperclass.

  • It is also worth noting that not onlycan you add to the functionality of a superclass, but you can modify existing functionality as well. This is achieved through overriding a method in one's superclass. To override asuperclass' method, you would implement your own method with thesame signature as your superclass' method. Thus, the JavaVirtual machine would use your implementation rather than your superclass'. Of course, you can explicitly use your superclass'methods and fields using the "super" keyword such as:

    super.methodname();

  • The super keyword is particularly important when working with Constructors because subclasses do notinherit the constructors of their superclasses. Thus, in orderto utilize the constructor of your superclass, you must explicitlycall it using the super keyword such as in the following example:

    class myFrame extends Frame
      {
      public myFrame()
        {
        super();
        }
      public myFrame(String title)
        {
        super(title);
        }
       ...the rest of your methods and fields....
      }

    Java also provides the "final" keywordwhich prevent a class from being subclassed, a method from being overridden and a variable from changing itsinitialized value. However, it is rarely used for regular application code.

Previous Page |Next Page