File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface Questioin

 
Harry Singh
Ranch Hand
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Regards,
Harjinder
 
Nick Shrine
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
 
Anupreet Arora
Ranch Hand
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Cheers
Anupreet
 
Harry Singh
Ranch Hand
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Regards,
Harjinder
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic