<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.scott5.org/index.php?action=history&amp;feed=atom&amp;title=Java_Objects</id>
	<title>Java Objects - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.scott5.org/index.php?action=history&amp;feed=atom&amp;title=Java_Objects"/>
	<link rel="alternate" type="text/html" href="https://wiki.scott5.org/index.php?title=Java_Objects&amp;action=history"/>
	<updated>2026-05-27T19:24:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://wiki.scott5.org/index.php?title=Java_Objects&amp;diff=155&amp;oldid=prev</id>
		<title>Scott: /* Callbacks: */</title>
		<link rel="alternate" type="text/html" href="https://wiki.scott5.org/index.php?title=Java_Objects&amp;diff=155&amp;oldid=prev"/>
		<updated>2011-01-31T21:55:46Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Callbacks:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Inheritance==&lt;br /&gt;
&lt;br /&gt;
Creating a subclass:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
class SubClass extends SuperClass{}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Polymorphism==&lt;br /&gt;
The subclass automatically inherits the superclass&amp;#039;s methods. These may be overridden as needed. &amp;quot;Dynamic binding&amp;quot; refers to the fact that the version of an overloaded function which gets used is decided at runtime, based on the type of the object making the call. A subclass&amp;#039;s constructor may use the superclass&amp;#039;s constructor as super, but this must be the first command:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public SubClass(int n){&lt;br /&gt;
   super(n-1);  //SuperClass&amp;#039;s constructor&lt;br /&gt;
   ...other setup...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Accessing superclass versions of methods from a subclass: &amp;lt;span id=&amp;quot;line-23&amp;quot; class=&amp;quot;anchor&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span id=&amp;quot;line-24&amp;quot; class=&amp;quot;anchor&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
super.someFunction(String s);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using subtypes and casting:super.someFunction(String s);&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
SuperClass a = new SubClass();&lt;br /&gt;
SubClass b = (SubClass)a;&lt;br /&gt;
(a instanceof SuperClass)  //true&lt;br /&gt;
(a instanceof SubClass)  //true&lt;br /&gt;
SuperClass c = new SuperClass;&lt;br /&gt;
(c instanceof SubClass)  //false&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Abstract Classes==&lt;br /&gt;
Create an abstract class with&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
abstract class MyClass{}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An abstract class may contain abstract methods:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public abstract method1(int n);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Abstract methods don&amp;#039;t have an implementation. Any nonabstract class that extends an abstract class must provide an implementation for any abstract methods.&lt;br /&gt;
&lt;br /&gt;
==Protected==&lt;br /&gt;
&lt;br /&gt;
A protected method is visible to subclasses (and to the current package).&lt;br /&gt;
&lt;br /&gt;
Protected attributes should be used with caution.&lt;br /&gt;
&lt;br /&gt;
==Reflection==&lt;br /&gt;
Given an arbitrary object at runtime, you can get all the information about its class: the type, fields, constructors, and methods. In addition, you can execute an arbitrary method.&lt;br /&gt;
&lt;br /&gt;
==Interface==&lt;br /&gt;
This is Java&amp;#039;s way of implementing multiple inheritance.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
class MyClass implements Interface1{}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An interface can be instantiated (but not with new()). An interface doesn&amp;#039;t have a constructor.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
Interface1[] i1Array;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An interface can have subinterfaces:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
interface SubInter extends SuperInter{}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Callbacks===&lt;br /&gt;
Interfaces are the preferred way of having an instantiated object talk back to its instantiator: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
class Instantiator implements ActionListener {&lt;br /&gt;
  MyProcess mp;&lt;br /&gt;
  public void doProcess(){&lt;br /&gt;
    mp = new MyProcess(this);&lt;br /&gt;
    mp.run();&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void actionPerformed(...){&lt;br /&gt;
    ...now the process is finished...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class MyProcess extends Thread {&lt;br /&gt;
  ActionListener al;&lt;br /&gt;
  MyProcess(ActionListener){...}&lt;br /&gt;
  public void run(){&lt;br /&gt;
    ...do stuff..&lt;br /&gt;
    //now call back&lt;br /&gt;
    al.actionPerformed(...);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Scott</name></author>
	</entry>
</feed>