click below
click below
Normal Size Small Size show me how
Java Final
Java I - Final Exam
Question | Answer |
---|---|
what is an interface in Java | a collection of constants and methods |
can an interface ever contain method bodies | no |
when a class implements an interface, what must it do | it must declare and provide a method of body for each method in the interface |
(True/False) a child class can extend just on parent and can implement zero or more interfaces | true |
Is the following a correct way to start out an interface class definition: public class SomeClass implements MyInterface | Yes --SomeClass is automatically a child of the class Object |
Look at the following interface: interface Taxable {double taxRate = 0.06 ; double calculateTax();} is the interface correct? | Yes -- taxRate will automatically be a constant since it is in an interface |
Can an Interface name be used as the type of a variable, like this: public static void main (String [] args) {SomeInterface x: ...} | Yes--the variable can refer to any object who's class implements the interface |
Is it OK if a class definition implements two different interfaces, each of which has the same definition for the constant PI? | No--=if a class implements several interfaces, each constant must be defined in only one interface |
Can an intefrace be given the private access modifier | No--then the interface would never be used |
Can an interface extend another interface | Yes |