[Advanced-java] Interface and Object class
BHARAT MEHTA
mrbharatmehta at gmail.com
Wed Apr 1 06:47:04 PDT 2009
Hi* **Ever*yone*,*I came across this post while searching on Google. Here it
goes:
I don't think so that an interface is derived from object. In the code
below:
Test t = new Test();
ITest it = t;
Object ob = it;
System.out.println(it.toString());
the toString() method is called using reference of Interface ITest
which ultimately points to the object of type Test(which is a kind of
subclass for Object class).
Now when we say it.toString() the method that is being called is
method on the object of class Test. JVM checks the type of the object
at the run time here (which happens to be of Test(a child of Object)
type)
Thanks,
Bharat Mehta
Interface and Object class *Sunil Jain* SJain at eGain.com
<advanced-java%40lists.xcf.berkeley.edu?Subject=Interface%20and%20Object%20class&In-Reply-To=>
*Thu May 18 11:54:22 PDT 2000*
- Previous message: your advice on DBMS and its driver on Linux
<http://lists.xcf.berkeley.edu/lists/advanced-java/2000-May/029355.html>
- Next message: Interface and Object class
<http://lists.xcf.berkeley.edu/lists/advanced-java/2000-May/029365.html>
- *Messages sorted by:* [ date
]<http://lists.xcf.berkeley.edu/lists/advanced-java/2000-May/date.html#29356>
[
thread ]<http://lists.xcf.berkeley.edu/lists/advanced-java/2000-May/thread.html#29356>
[
subject ]<http://lists.xcf.berkeley.edu/lists/advanced-java/2000-May/subject.html#29356>
[
author ]<http://lists.xcf.berkeley.edu/lists/advanced-java/2000-May/author.html#29356>
------------------------------
Are Interfaces derived from Object class ?
The following java program works, how ??
class Test implements ITest{
public static void main(String[] args){
Test t = new Test();
ITest it = t;
Object ob = it;
System.out.println(it.toString());
}
public void add(){
}
}
------------------------------------------
interface ITest{
void add();
}
-------------------------------------------
Sunil Jain
---
To unsubscribe, mail advanced-java-unsubscribe at xcf.berkeley.edu
<http://lists.xcf.berkeley.edu/mailman/listinfo/advanced-java>
To get help, mail advanced-java-help at xcf.berkeley.edu
<http://lists.xcf.berkeley.edu/mailman/listinfo/advanced-java>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /lists/advanced-java/attachments/20090401/55cd6d93/attachment.html
More information about the Advanced-java
mailing list