OOP (Java) Final Exam
OOP (Java) Final Exam
General Instructions:
✓ write all answers on the attached papers except Part-I
✓ Make sure the exam paper contain four(4) parts and 4 pages including the cover page
For Instructors
40 %
1
Part I- Error finding and rewrite the corrected code in the box given
1.) Can you identify the error in the below code?(2pts)
interfaceA
{
privateinti;
}
interfaceX
{
voidmethodX();
void dis();
}
classY implementsX
{
voidmethodX()
{
System.out.println("Method X");
}
}
interfaceA
{
inti = 111;
}
classB extendsA
{
voidmethodB()
{
i = 222;
}
}
2
Part-II Essay
Instruction : your handwriting should be readable, unreadable answer worth
nothing .
1.) What are the different ways to print exception message on console and
explain each them with examples?( 3pts)
2.) Explain the main difference between throw and throws with examples .( 3pts)
3.) Describe all access modifiers in details within the same package and
different package with examples . (4pts)
4.) Briefly explain the difference between abstract class and interface , support
your answer by example . (3pts)
select from the given exception type and match with the corresponding case , write
the reason on the attached answer sheet (5%)
A Checked exception
B user defined exception
C unchecked exception
D asynchronous exception
1. A java program that tries to read data from flash, but the flash is not working or
corrupted.
2. A programmer made a mistake during creation of an object using unavailable class.
3. First year ASTU student made a mistake during registration period inserting name in
the filled of date of birth.
4. a given bank system check the current balance before processing withdraw and
transfer fund
5. A java program that tries to access empty array in the java program
3
Part IV- Program Writing
1. write a java program that create a registration of extension students that check either
a student is eligible or not, based on grade 12 result using user defined/custom
exception , if the grade 12 result is <300 it display you are not eligible else registered
student . (5pts)
2. write a java program that read student information from GUI and register students in
the file or in the database and it also display all registered students in the screen/in the
Grid/Jtable
i. Design GUI with the following attributes name ,ID, Gender and
department (3pts)
ii. write data from GUI to file or database (4pts)
iii. read data from file or database and display on the screen or Jtable
(3pts)