Which of these can be used to fully abstract a class from its implementation
Java Programming Multiple Choice Questions - InterfacesThis section focuses on the "Interfaces" in Java programming. These Multiple Choice Questions (MCQ) should be practiced to improve the Java programming skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements and other competitive examinations. Show
1. Which of these keywords is used to define interfaces in Java? A. interface View Answer 2. A java interface can contain _______. A. Abstract methods(unimplemented) and implemented methods both View Answer 3. Which of these access
specifiers can be used for an interface? A. Public View Answer 4. Which of the following is a correct interface? A. abstract interface A { abstract void print(); { }} View Answer 5. Which of the following classes directly implement Set interface? A. Vector View Answer 6. Which of these keywords is used by a class to use an interface defined previously? A. Import View Answer 7. Which is the correct way to inherit and implement the interface? A. class Cat implements IAnimal{} View Answer 8. which of the following is true about methods in an interface in java? A. An interface can contain only
abstract method. View Answer 9. Which of the following is the correct way of implementing an interface salary by class manager? A. class manager imports salary {} 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 View Answer 11. Which of these can be used to fully abstract a class from its implementation? A. Objects View Answer 12. What is the output of this program? interface calculate { void cal(int item); } class display implements calculate { int x; public void cal(int item) { x = item * item; } } class Main { public static void main(String args[]) { display arr = new display(); arr.x = 0; arr.cal(2); System.out.print(arr.x); } } A. 0 View Answer 13. All methods must be implemented of an interface. A. TRUE View Answer 14. What type of variable can be defined in an interface? A. public static View Answer 15. What does an interface contain? A. Method definition View Answer 16. What type of methods an interface contain by default? A. abstract View Answer 17. What will happen if we provide concrete implementation of method in interface? A. The concrete class implementing that method need not provide implementation of that method View Answer 18. What happens when a constructor is
defined for an interface? A. Compilation failure View Answer 19. What happens when we access the same variable defined in two interfaces implemented by the same class? A. Compilation failure View Answer 20. Can "abstract" keyword be used with constructor, Initialization Block, Instance Initialization and Static Initialization Block. A. TRUE View Answer Also check :
Discussion THANUJA ROY M ROY Thank you What are the implementation classes of the set interface Mcq?Classes that implement Set. HashSet.. LinkedHashSet.. EnumSet.. TreeSet.. Which of the following is the correct way of implementing an interface salary by class manager in Java?
Which keyword is used for correct implementation of an interface in C# net?In C#, an interface can be defined using the interface keyword. An interface can contain declarations of methods, properties, indexers, and events.
Which of the following is the correct way of implementing an interface person by class doctor?Which of the following is the correct way of implementing an interface A by class B? Explanation: Concrete class implements an interface.
|