The Artima Developer Community
Sponsored Link

Java Answers Forum
interface question

1 reply on 1 page. Most recent reply: Feb 23, 2003 9:06 AM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
utpal

Posts: 1
Nickname: matu
Registered: Feb, 2003

interface question Posted: Feb 22, 2003 9:48 PM
Reply to this message Reply
Advertisement
Hi all i had a doubt.
Do interfaces inherit from the OBJECT class??I think no.

For example ( Comparable is an interface ) .And we can have varibles of an interface in Java ,, so

Comparable obj = new fruit();
String na1 = obj.getName(); // Assuming getName() in in fruit

obj.getName generates an error because Comparable is an inteface that can not have any implementation for getName() (inheritance concept).

But if we say " obj.toString() " ( toString() is a function
in the Object class ) , this is said to work ,unless obj inherits the "toString()" function , how can it access toString in Class fruit.(If obj could not access getName() then it shouldnt be able to access toString() also ).

Please throw some light on this.
Regards ,
matu


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: interface question Posted: Feb 23, 2003 9:06 AM
Reply to this message Reply
String implements Comparable

Flat View: This topic has 1 reply on 1 page
Topic: encryption Previous Topic   Next Topic Topic: polymorphism and inheritance

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use