This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

interface

 
ronak mehta
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can interface is intantiated?
if no
then
interface Inter{}
class A implements Inter
class B extends A
{
A a=new B();
Inter i=a;
}
is legal?
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.
You can even do this:

[This message has been edited by Thomas Paul (edited August 31, 2001).]
 
Roopa Bagur
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your example you are using the Interface as a variable type that is all. Java lets you use Interface name as variable type as long as the variable is referencing a class that implements that interface.
Originally posted by ronak mehta:
can interface is intantiated?
if no
then
interface Inter{}
class A implements Inter
class B extends A
{
A a=new B();
Inter i=a;
}
is legal?

 
Nothing? Or something? Like this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!