Question Bank
: Java Programming (9113)
Class
: TYIF (IF/V/C)
Chapter No. 03
Interfaces and Packages
Review Questions from previous MSBTE question papers: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19.
Give the syntax of creating and implementing the interface. Differentiate between abstract class and an interface. Explain all the ways in which a multiple inheritance can be implemented. What are the characteristics of data members defined inside the interfaces? How can we inherit an interface from another? Explain the differences between and class and the interface. How can we achieve the run time polymorphism using interfaces? Can we implement one interface from another? How? What will happen if a derived class does not override all the methods of the interface? What will be the solution on it? Give the characteristics and applications of an interface. Explain the system class hierarchy of Java. How do we tell Java program that we want to use a particular package in a file? How can we add any class or interface to the package. Which are the restrictions provided by default access of the class? Give different forms of an import statement in the program. Explain static import with appropriate example. Explain classes can be hidden using package access? Which is the default package imported in a Java program? Comment on following two statements:
import java.io.*; import java.io.File; 20. Which are the naming conventions used for naming a package? Programming exercises: 1.
Implement the inheritance given below by assuming suitable methods. Class: Student
Interface: Exam
Roll no, name
Percentage
Class: Result Grade 2.
Define a class ‘Employee’ having data members name and basicsalary. Also declare an interface ‘Gross’ having method to calculate
-1-
3.
gross salary. Derive a class ‘Salary’ using class ‘Employee’ and interface ‘Gross’ and display the name, basic-salary and gross-salary. Implement the inheritance given below by assuming suitable methods.
Class: Person
Interface: Manager
Name, address
accept( ), salary( )
Class: Employee ID, basic
-2-