Object Oriented Programming
CSE · Final · Spring 23
Paper 1 of 2Batch 61Switch
Batch 61
Paper 1 of 2
Read the questions as text
Read off the PDF by AI, so it may have mistakes. The PDF is the original.
Daffodil International University
Faculty of Science & Information Technology
Final Examination, Spring 2023
Course Code: CSE214: Course Title: Object Oriented Programming
Level: 2 Term: 1 Batch: 61
Time: 2:00 Hrs
Marks: 40
Answer ALL Questions [Optional]
[The figures in the right margin indicate the full marks and corresponding course outcomes. All portions of each question must be answered sequentially.]
1. Identify the errors if found and trace the output from the following program:
public static void main(String args[]) {
try {
int d = 0;
int n = 20;
int fraction = n / d;
int g[] = {1};
g[20] = 100;
}
catch (ArithmeticException e) {
System.out.println("ArithmeticException ");
}
catch (ArrayIndexOutOfBoundsException e) {
System.out.println("ArrayIndexOutOfBounds");
}
System.out.println("End Of Main");
}
[2] CO1
2. a) “A block of code which always executes, irrespective of occurrence of an exception”
-Explain the statement with proper coding examples. Find out the output of the following code?
public class Test
{
private void m1()
{
m2();
System.out.printf("11");
}
private void m2()
{
m3();
System.out.printf("22");
}
private void m3()
{
System.out.printf("33");
try
{
int sum = 4/0;
System.out.printf("44");
}
catch(ArithmeticException e)
{
System.out.printf("55");
}
catch(Exception e)
{
System.out.printf("66");
}
finally
{
System.out.printf("77");
}
System.out.printf("88");
}
public static void main(String[] args)
{
Test obj = new Test();
obj.m1();
}
}
[6] CO2
b) Explain multithreading with proper code. [i.e. Create 3 threads where the output will be “This code is running in the thread number #”, the threads should be created using Runnable class]
[5]
3. Analyze UML diagram to develop Java code from the following
[Figure: UML class diagram showing Person, Employee, PartTime, FullTime, and HR classes with attributes and methods]
[7] CO3
4. a) Develop a java code while applying the principles of OOP by making the following Input and Output visible.
Input:
Enter first number: 13
Enter second number: 5
Output:
Addition = 18
Subtraction = 8
Quotient = 2
Reminder = 3
[5] CO4
b) Daffodil International University has its own 1Card system rather than relying on software from a vendor. This software allows a 1Card holder to use his or her card to make different kinds of payments on campus. He or she can also use the card as a debit card, meaning that he/she can deposit money (int) into an associated account. Students are only able to use their 1Cards to pay various university-related fees: parking fees, library fees, gym fees, transportation fees, DIU locker fees, and tuition fees. For making a payment, students have to give the payment gateway name (Bkash, Master Card, or Visa card) (string), the amount (int), and their pin number (int). The system keeps a usage record of every use of the 1Card. And the student can see the whole transaction list with the details of the transaction name (string), transaction date (string), and transaction amount (int). This software also has the feature of making a payment through a QR code scan. Students can access the university news portal through the software. This software is built for students and guardians. For a student, he or she has all the features that have been mentioned above, but for a guardian, they only have one feature, which is tuition fees payment. Students have to enter their email and password into the input field (they are both strings), and guardians have to enter their studentID (string) in the input field.
Now, develop a class diagram and write Java Code with the relationship between the classes. What types of relationships does it refer to?
[15]