File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Interface" Watch "Interface" New topic
Author

Interface

devi nachimuthu
Greenhorn

Joined: Jan 07, 2003
Posts: 10
Can some body please explain me about the interfaces.....? Does the interface contains variables, constructors...? Can it be instantiated...?
I also have the following question, that i cannot understand...?
Given the following classes, which of the following will compile without error...?
interface IFace{}
class CFace implements IFace {}
class Base{}
public class ObRef extends Base {
public static void main(String argv[]) {
ObRef ob = new ObRef();
Base b = new Base();
Object o1 = new Object();
IFace o2 = new CFace();
}
}
1) o1 = o2;
2) b = ob;
3) ob = b;
4)o1 = b;
The given answers are 1,2,4.
Can somebody please explain about the 1.
Paul A
Ranch Hand

Joined: Aug 25, 2000
Posts: 44
'o1' is a variable of class Object. As you know that all objects eventually extend from Object class, the object refered to by the variable 'o2' will also be an Object.
So it is legal to set o1 to point to o2.
For info about interface, I would suggest you to read Java Tutorial on Sun site. It is very good.
------------------
http://pages.about.com/jqplus
Get Certified, Guaranteed!


<A HREF="http://pages.about.com/jqplus" TARGET=_blank rel="nofollow">http://pages.about.com/jqplus</A> <BR>Get Certified, Guaranteed!
 
 
subject: Interface
 
Threads others viewed
Marcus Exam#2 Q50
Marcus Green exam 2 Q.50
Interface question
where is the Object o1 come from?
IntelliJ Java IDE