473,322 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

RunTime Polymorphism Related Question

When a super interface variable holds a subclass object, then according to run time polymorphisms we can access those methods which are declared in super interface or has been overridden in subclass. So my question is ..........

How we get access to Object class methods like equal() on that reference variable, which is opposed to runtime polymorphisms, because equal() method has not been declared in Super Interface for which I'm taking about.

Please do answer this question. I'm hanking after this question

Vishal Agrawal
Feb 11 '08 #1
1 1231
BigDaddyLH
1,216 Expert 1GB
It never hurts to illustrate your question with sample code, especially when it's not totally clear. I think you are asking this:

Expand|Select|Wrap|Line Numbers
  1. interface I {
  2.     void m();
  3. }
  4.  
  5. class Test {
  6.     void f(I x, Object another) {
  7.         if (x.equals(another)) { //how can I do this?
  8.  
  9.        }
  10.     }
  11. }
The answer is go ahead and do it -- it's legal and works as you expect.

Formally, in the JLS section 9.2: http://java.sun.com/docs/books/jls/t...faces.html#9.2

If an interface has no direct superinterfaces, then the interface implicitly declares a public abstract member method m with signature s, return type r, and throws clause t corresponding to each public instance method m with signature s, return type r, and throws clause t declared in Object, unless a method with the same signature, same return type, and a compatible throws clause is explicitly declared by the interface. It is a compile-time error if the interface explicitly declares such a method m in the case where m is declared to be final in Object.
Feb 11 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

37
by: Mike Meng | last post by:
hi all, I'm a newbie Python programmer with a C++ brain inside. I have a lightweight framework in which I design a base class and expect user to extend. In other part of the framework, I heavily...
3
by: Patchwork | last post by:
Hi Everyone, Please take a look at the following (simple and fun) program: //////////////////////////////////////////////////////////////////////////// ///////////// // Monster Munch, example...
35
by: JKop | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en- us/vccore98/HTML/_core_using_strict_type_checking.asp Pay particular attention to: The types WPARAM, LPARAM, LRESULT, and void *...
9
by: Charisma | last post by:
I have a client who is requesting the following: Description: -database should be a runtime version of MS Access so that it would not be necessary for the user to have any Microsoft products in...
4
by: LP | last post by:
Hi, I understand the concept/definition of polymorphism. But what does the term "runtime polymorphism" mean? I was asked to define it during a technical interview. I gave a guy vanilla definition...
4
by: arunvnk | last post by:
It is not quite clear why the compiler uses rntime polymorphism when the virtual keyword is specified. Since the virtual Keyword is specified,why can't the compiler decide at the runtime...
7
by: doina | last post by:
Hello, Can I have runtime polymorphism using references. I knew that runtime polymorphism could be obtained only by pointers, but now I have tried this in Visual C++ 8.0: #include <iostream>...
11
by: chsalvia | last post by:
I've been programming in C++ for a little over 2 years, and I still find myself wondering when I should use polymorphism. Some people claim that polymorphism is such an integral part of C++,...
16
by: desktop | last post by:
I have read that using templates makes types know at compile time and using inheritance the types are first decided at runtime. The use of pointers and casts also indicates that the types will...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.