This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
You have mentioned that an interface cannot be instantiated but an abstract class can be.....
To what i can say is abstract class can never be instantiated as per i know,we can just inherit the methods of abstract class that is for it is abstract isnt it?
Thanks for correcting dhwani. I was just intended to say the "inheritance hierarchy" but while the way i was typing, it got a typo that "instantiate". Its edited now.
Thank you.
dhwani mathur
Ranch Hand
Joined: May 08, 2007
Posts: 621
posted
0
You are Welcome Raghavan!!!
Krishna Chaitanya Reddy Kuninti
Greenhorn
Joined: May 29, 2007
Posts: 13
posted
0
Hi all,
I tried to write an interface that extends(inherits) a pure abstract class and find some facts.
1) An Interface can extend(inherits) only another interface.
2)An Interface can not extend(inherits) any other class, abstract class with non-abstract methods and pure abstract class(abstract class having all abstract methods).
In other way, there can be a super interface for an interface but there can not be a superclass for an interface.
Krishna Chaitanya Reddy Kuninti
Greenhorn
Joined: May 29, 2007
Posts: 13
posted
0
Hi all, Hi all,
When I tried to write an interface that extends(inherits) a pure abstract class, I have found the following facts.
1) An Interface can extend(inherits) only another interface.
2)An Interface can not extend(inherits) any other class, abstract class with non-abstract methods and pure abstract class(abstract class having all abstract methods).
In other way, there can be a super interface for an interface but there can not be a superclass for an interface.
Trial and error is one way to find out the answer to these questions, but it can lead to misunderstandings and bad assumptions.
The best way to find out what is allowed in the language is to read the Java Language Specification, which is available on-line for free. For instance, here is the section on interfaces, which tells you what is and is not legal.
By the way, while what you called a "pure abstract class" (a class with no concrete methods) is legal in Java, it is rarely useful. Why would you not want to use an interface? Perhaps you have come from C++, where interfaces are not a separate kind of thing and are instead represented as "pure-virtual classes". [ July 31, 2007: Message edited by: Peter Chase ]
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P