If a class is using an interface, it must:
(1) inherit the properties of the interface
(2) contain the same methods as the interface
(3) create an interface object
(4) all of the above
And the correct answer is (4)all of the above.
Note: this comes from here and I have no idea who actually is the author of the question.
I agree to the (1)st and (2)nd, but I would argue over the wording of the (3)rd.
I guess it could be dually interpreted;
Create an interface object could mean just an instance of a class that inherits an interface
or
A reference variable of the Interface type
What is the correct way of interpreting the above?
Would the below make sense?
If a class is using an interface, it must:
(1) inherit the properties of the interface
(2) provide implementation for all methods that the interface exposes
(3) ???
(4) all of the above
(2) provide implementation for all methods that the interface exposes
No. Abstract classes can implement an interface without providing an implementation (they still have to declare the methods defined in the interface, but they don't have to provide a body).
I wouldn't know how to interpret number 3 either though. When looking trough the link you have provided it's just a matter of badly worded questions. I'm still trying to figure out what this means:
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments