COSC 2011 Section N
Sample Questions

Interfaces


Questions

1 Here is the complete code for a proposed interface:

Interface Swoffable{
   int left = 1, right = 2;
   void doSwoff(int direction);
}
Which of the following statements about the code is true?
a. The compiler will object to declarations of variables in an interface
b. Only classes implementing Swoffable will be able to refer to the left and right variables.
c. Programs will be able to treat Swoffable.left and Swoffable.right as constants.
d. None of the above.
2 You can't define an interface by extending another interface.
a. True
b. False
Answers:

1.  d)  Variables declared in an interface must be constants!
2.  b)  You certainly can have one interface extend another.