T4Tutorials .PK

Chapter 6 Interfaces MCQs

1. . Which of the following is true about methods in an interface in Java?

(A) Private and protected access modifiers can also be used to declare methods in interface


(B) We can define a method in an interface


(C) An interface can contain only abstract method.


(D) None




2. . Which one is correct declaration for implementing two interfaces? Consider Interface A and B. class C wants to implement both interfaces.

(A) class C implements A, implements B


(B) class C implements A, B


(C) class C implements A extends B


(D) None




3. . Which of these access specifiers can be used for an interface?

(A) Public


(B) Protected


(C) Private


(D) Any of the above




4. . Choose a correct statement about Java Interfaces?

(A) All the above


(B) A Java class can implement multiple interfaces


(C) An Interface can extend or inherit another Interface.


(D) Interface contains only abstract methods by default.




5. . Which is correct option about java interface?

(A) Interface is used to achieve multiple inheritance in java


(B) All of the above


(C) An interface can extend another interface.


(D) Object of an interface cannot be created.




6. . False statement about Java interface

(A) It is used to achieve abstraction and multiple inheritance in Java.


(B) There can be only abstract methods in the interface not method body.


(C) It can be instantiated, means, we can create an object of an interface.


(D) All are correct.




7. . Java interface is used to

(A) Implement behavior of multiple inheritance


(B) Achieve abstraction


(C) Achieve loose coupling


(D) All of the above




8. . Which is true statements about an interface in Java?

(A) An interface can have constructor


(B) We can create object of an interface in java


(C) An interface can extend another interface


(D) None




9. . An interface in Java is like a 100% ____

(A) abstract class


(B) public class


(C) inner class


(D) anonymous class




10. . A class inherits an interface using which keyword?

(A) Extends


(B) Implements


(C) Inherit


(D) None




11. . Which of these keywords is used to define interfaces in Java?

(A) intf


(B) Interface


(C) interface


(D) Intf




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

(A) class manager extends salary{}


(B) none of the mentioned


(C) class manager imports salary{}


(D) class manager implements salary{}




13. . A Java Class inherits Constants and Methods of an Interface using ____ keyword.

(A) EXTENDS


(B) IMPLEMENTS


(C) INTERFACE


(D) All the above




Exit mobile version