Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
For 2023 - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))

Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
Java module J710
Extending Classes and More
Exercises, examples and other material relating to training module J710. This topic is presented on public courses Learning to Program in Java, Java Bootcamp, Java Programming for the Web

Learn how to implement inheritance in Java, and how Java handles Polymorphism. Java also provides the concepts of abstract classes and interfaces, which are also covered by this module.

Articles and tips on this subjectupdated
4422Objects - from physical to virtual or abstract - Java
A train, a person, a dog, a signpost, a meal, a station ... they're all similar objects in programming terms. We can set them up in our program, save and restore attributes - and they make an excellent teaching parallel comparing real life things ("objects") of a certain type ("class").   ...
4419Java Inheritance example - group of classes - step by step
Two examples from last week's Java course ... a) [here] - an example of a base class, two classes that inherit from it, and a test class. b) [here] - that same example extende to add • an array of objects of various associated types (so polymophism in action) • an abtract class, meaning that ...
4394Philosophy behind object design - and how I applied in to a Java example
* When you're writing all the logic to deal with a particular type of data, it's a good idea to write it into a CLASS * Where you have similar types of data, it's a good idea to put the shared logic into a BASE CLASS and then write SUBCLASSES which are based on that base class. That way your common ...
4366Changing what operators do on objects - a comparison across different programming languages
In Object Oriented languages, you used named pieces of code known as methods to perform an operation on a variable - for example you might write   weeklist.extend(weekend) to take a list of (something) for a week and add a list relating to weekend onto the end of it. Sometimes, the method ...
4334Splitting out code into name blocks for clarity and reusability
When you first write code - "a program" - there's a big temptation to start at the top and write on down to the bottom, putting all the code more or less sequentially in your program's source file. In the case of Java, which I was teaching last week, that would have meant within the main method (we ...
3047What is a universal superclass? Java / Perl / Python / Other OO languages
In any object oriented language, all objects will ultimately inherit from a base class supplied with the language, whether it's explicitly stated or not. That's because every class that you write will need that basic facilities to set up members (objects), and it's also useful to provide you with a ...
2860What methods are available on this Java object?
Q: "What can I do with an ArrayIndexOutOfBoundsException?" for example ... A: Use the javap utility to ask what methods are available on the class ... and descent into its base class structure too, using further javap calls: wizard:java graham$ javap java.lang.ArrayIndexOutOfBoundsException Compiled ...
2604Tips for writing a test program (Ruby / Python / Java)
Where does my test code go? If you've written a class - a series of methods to be used within another application - how do you test it? How about writing a test program within the same file which runs as the main program if you run your class on its own from the command line, but is ignored if you ...
2434Abstract classes, Interfaces, PHP and Java
Abstract classes, Interfaces, PHP and Java Basics. When you design code for a number of different similar type of thing (object types, classes) you don't start from scratch in each case - you define a base class which contains all the common code, and you then create subclasses by extending the original. ...
2185Abstract Classes - Java
In Java you can write a class from scratch, or you can write one class based on another, using the 'extends' keyword and providing only the methods that change in the new class from the base class, plus any extras. Let's say we're writing an accounts system, for example ... we have a base class that's ...
1294An example of Java Inheritance from scratch
One of the most important topics for newcomers to OO (Object oriented) programming to learn is how to design their classes and make best use of inheritance, and I find myself writing new examples from first principles during our courses. That way, the delegates learn how to actually do the job - they're ...
1819Calling base class constructors
In all object oriented languages, you have a facility called inheritance where you can define one type of thing ("class of object") based on another, and the newly defined class ("subclass" or "extended class") takes the initial ("base") class as it starting point. In your code for your base class, ...
1556Java - a demonstration of inheritance on just one page
Here's a challenge, just given to me by my Java Delegates, to put my complete example of a Rectangle and a a Circle class, both inheriting from a Shape base class, and a test harness ... on on a single screen. A bit tight, and a bit uncommented, but here it is! public class Circle extends Shape { int ...
1538Teaching Object Oriented Java with Students and Ice Cream
"I'm getting tired of students. Can we do something else". So said my delegates at Cardiff University today. So we did Ice Cream and other deserts! Perhaps I had better explain. I'm running a Java Course there, and looking for examples of classes and objects to write about. At the start of the course, ...
1501Java - using super to call a method in the parent class
If you're writing a Java class in which you override a method from the base class, can you still make use of that base class method in your new code? Yes, you can. You want the super call. Here's an example - I had a base class called Shape which overrides the toString method. And I was then writing ...
1217What are factory and singleton classes?
Do you find some of the OO terminolgy baffling? Once you've learnt about constructors and methods, inheritance, overloading and polymorphism and statics, you might think you're there. Then someone mentions a "factory class" or a "singleton" ... Fear not - factory and singleton classes are posh names ...
1066Final, Finally and Finalize - three special words in Java
A final method or variable is one that can't be overridden - you can define a method as final within a class to ensure that any extensions to the class don't replace it. If you add a finally block onto the end of a try / catch exception handler, you're defining a block of code that will be run if the ...
831Comparison of Object Oriented Philosophy - Python, Java, C++, Perl
There are two different philosophies that have been adopted by the authors of Object Oriented languages. The first approach is to set the thing up in such a way that a programmer who uses someone else's code as the basis for his isn't going to be trusted to use that other person's code in a sensible ...
656Think about your design even if you don't use full UML
Even if you don't feel that your project is big enough to get involved with formal design methods, many of the lessons of UML and some informal design diagrams can help you get a clear view of what you're going to be doing be for you start, and can help you come up a good, thought out and reliable plan ...
Examples from our training material
Babysitter.java   Application that uses Hire, Cinema and TV films
BaseFile.java   An abstract base class
Book.java   Inheriting from the Universal Superclass. Also test harness in same file as class.
Car.java   Class that implements an interface
Cinema.java   extended class example
Hire.java   Hire Film - extended class
HireFilm.java   Class HireFilm (extends film from other module)
Hires.java   Application to use HireFilm
House.java   Another class than implements an interface
Interit.java   Interitance demo bundle - 4 files in Java
Interit2.java   Interitance bundle + array, abstract, super, overload
Ipay.java   Application using an array of objects that implement an interface
Lecture.java   Lecture - application for exercise
Lecturer.java   Lecturer - subclass for use in exercise
Lunch.java   Using methods inherited from the base class Object
People.java   People - base class for use in exercise
Round.java   Exercise template - calculate price of a round
Student.java   second subclass for use in exercise
Tv.java   Another extended class - TV
User.java   Hiding detailed logic in (static) methods
insurable.java   Interface definition
Students learning Java on a private course
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from [here].
Topics covered in this module
Extended classes.
Abstract Classes.
Getting your design right.
The universal superclass.
The final modifier.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Java,Ruby, Lua, Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses at our training centre in Melksham, Wiltshire, England. It's surprisingly cost effective to come on our public courses - even if you live in a different country or continent to us.

We have a technical library of over 700 books on the subjects on which we teach. These books are available for reference at our training centre.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2023: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/J710.html • PAGE BUILT: Sun Oct 11 14:50:09 2020 • BUILD SYSTEM: JelliaJamb