The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
August 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

RE:Is it possible to implement Class references in Java

Posted by Kishori Sharan on August 14, 2000 at 4:15 PM

Hi
I don't know Delhi and Object Pascal so I can't understand the example code you have written. What I got from your problem description is as follows.
You have a method and which takes a parameter of a class, say Shape.
void aMethod ( Shape obj ) ; now since Circle is also a shape then can you pass an object of Circle class to aMethod.
If this is your quesry then please rean on else never mind.
Java supports inheritance and dynamic binding. This is possible in java. First you have to create a class Shape and add all the methods you want. Then create another class Circle inheriting Shape class. Now wherever as method parameter you expect an object of Shape class you can pass an object of Circle class just because a Circle is also a Shape ( because you inherited Circle from Shape ). Yo can refer to any standard java text book and read the topics Inheritance, Dynamic binding abd upcasting...

Thanx
Kishori




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us