File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interface Questioin 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 Questioin" Watch "Interface Questioin" New topic

Interface Questioin

Harry Singh
Ranch Hand

Joined: May 02, 2001
Posts: 124
HI all,
Just got this question on Interfaces in one of the mocks,
Select all correct answers about what is the definition of an interface?
A) It is a blue print
B) A new data type
C) Nothing but a class definition
D) To provide multiple inheritance
According to me the answer should be A and D. but according to the mock exam answers its A,B and D. How can an interface be Data type?
Nick Shrine

Joined: Jul 17, 2003
Posts: 11
I suppose because you can declare variables of that type e.g. if you have an interface called "myinterface" you can declare a variable:
myinterface myvar;

Nick<br />SCJP<br />SCJD
Anupreet Arora
Ranch Hand

Joined: Jun 17, 2003
Posts: 81
Hello Harjinder,
Looking up in the JLS produced this definition of an interface
An interface declaration introduces a new reference type whose members are classes, interfaces, constants and abstract methods. This type has no implementation, but otherwise unrelated classes can implement it by providing implementations for its abstract methods

So we can very well say that an interface is a new data type because we kind of take the term "data type" to be more generic form the term "reference type". U know we refer to objects using the term "reference types" and not to primitive types.
But ofcourse the option is somewhat confusing. What I feel is if you want to justify option B, you can do it, but it is not a very clear or straight forward choice.
Harry Singh
Ranch Hand

Joined: May 02, 2001
Posts: 124
Hi Pals,
Thanks for the replies. so going by that thinking that interfaces can be data type as we can reference new classtypes of other members through it, so acthat means an abstract class type or even a simple class declaration also should be a new data type. Isnt it wrong to say that classes, interfaces, abstract classes are new data types as they are not at all data types rather they are references and are not related to datatypes as such.
I agree. Here's the link:
subject: Interface Questioin
It's not a secret anymore!