Mcq On Java Interfaces

6. Which of these keywords is used by a class to use an interface defined previously?

A. Import
B. import
C. implements
D. Implements

View Answer


7. Which is the correct way to inherit and implement the interface?

A. class Cat implements IAnimal{}
B. class Cat import IAnimal{}
C. class Cat extends IAnimal{}
D. None is correct

View Answer


8. which of the following is true about methods in an interface in java?

A. An interface can contain only abstract method.
B. We can define a method in an interface
C. Private and protected access modifiers can also be used to declare methods in interface
D. None of the above

View Answer


9.Which of the following is the correct way of implementing an interface salary by class manager?

A. class manager imports salary {}
B. class manager implements salary {}
C. class manager extends salary {}
D. none of the mentioned


View Answer


10.Which of the following is an incorrect statement about packages?

A. Interfaces are specified public if they are to be accessed by any code in the program
B. Interfaces specifies what class must do but not how it does
C. All variables in interface are implicitly final and static
D. All variables are static and methods are public if interface is defined pubic

View Answer







Also check :


Discussion


* You must be logged in to add comment.