*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "interface" Watch "interface" New topic
Author

interface

ronak mehta
Greenhorn

Joined: Aug 14, 2001
Posts: 23
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

Joined: May 05, 2000
Posts: 13974
Yes.
You can even do this:

[This message has been edited by Thomas Paul (edited August 31, 2001).]


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
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?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: interface