Unfortunately, I cannot directly create or send PDF files.
However, I can provide you with the complete
content in a text format that you can easily copy and paste into a document (e.g., Word or Google Docs)
and then save as a PDF. Below is the **full content** of the solved PDF:
---
### **Daffodil International University**
**Faculty of Science and Information Technology**
**Department of CSE**
**Midterm Examination, Semester: Fall 2023**
**Course Code: CSE214**
**Course Title: Object Oriented Programming**
**Batch: 63**
**Section: All**
**Time: 01:30H**
**[Answer all the Questions. Obtain marks in the right side]**
**Full marks: 25**
---
### **1. a. Fundamental Paradigm Difference Between Structured Programming and Object-Oriented
Programming**
- **Structured Programming**:
- Focuses on procedures or functions.
- Programs are divided into functions or modules.
- Data and functions are separate.
- Emphasizes logic and control flow.
- Examples: C, Pascal.
- **Object-Oriented Programming (OOP)**:
- Focuses on objects that represent real-world entities.
- Programs are divided into classes and objects.
- Data and methods (functions) are encapsulated within objects.
- Emphasizes concepts like inheritance, polymorphism, encapsulation, and abstraction.
- Examples: Java, C++, Python.
---
### **1. b. Multiple Inheritance in Java**
- **Multiple Inheritance** is not supported in Java through classes.
- **Reason**: Java avoids the "diamond problem" (ambiguity that arises when a class inherits from two
classes that have a common ancestor).
- **Alternative**: Java supports multiple inheritance through **interfaces**. A class can implement
multiple interfaces, allowing it to inherit method signatures from multiple sources.
---
### **1. c. Interface vs Abstract Class**
- **Interface**:
- Contains only method signatures (no implementation).
- All methods are implicitly `public` and `abstract`.
- Variables are `public`, `static`, and `final` by default.
- A class can implement multiple interfaces.
- Used to define a contract for classes.
- **Abstract Class**:
- Can contain both abstract methods (without implementation) and concrete methods (with
implementation).
- Variables can be of any type (not just constants).
- A class can extend only one abstract class.
- Used to provide a partial implementation and define a common base for subclasses.
---
### **2. a. Class AREA with Method Overloading**
```java
class AREA {
// Method to calculate area of a rectangle
double calculateArea(double length, double width) {
return length * width;
// Method to calculate area of a circle
double calculateArea(double radius) {
return Math.PI * radius * radius;
// Method to calculate area of a triangle
double calculateArea(double base, double height, String shape) {
return 0.5 * base * height;
}
public class Main {
public static void main(String[] args) {
AREA area = new AREA();
System.out.println("Area of Rectangle: " + area.calculateArea(5, 10));
System.out.println("Area of Circle: " + area.calculateArea(7));
System.out.println("Area of Triangle: " + area.calculateArea(6, 8, "triangle"));
```
---
### **2. b. Error in the Code**
- **Error**: The code has a syntax error due to extra closing braces (`}`) at lines 7 and 13.
- **Corrected Code**:
```java
public class University {
public static void main(String[] args) {
Daffodil diu = new Department();
diu.display();
class Daffodil {
void display() {
System.out.println("Daffodil International University");
}
}
class Department extends Daffodil {
void display() {
System.out.println("Computer Science & Engineering");
```
- **Output**:
```
Computer Science & Engineering
```
- Explanation: The `Department` class overrides the `display()` method of the `Daffodil` class, so the
overridden method in `Department` is called.
---
### **3. Online Banking System**
#### **a. UML Class Diagram**
```
+-------------------+ +-------------------+ +-------------------+
| Customer | | Account | | SavingsAccount |
+-------------------+ +-------------------+ +-------------------+
| - customerID: int | | - accountNumber: int | | - interestRate: double |
| - name: String | | - balance: double | +-------------------+
| - address: String | | - accountType: String| | + calculateInterest() |
| - phone: String | +-------------------+ +-------------------+
+-------------------+ | + deposit(amount: double) |
| + deposit(amount: double) | + withdraw(amount: double) |
| + withdraw(amount: double)| + getBalance(): double |
+-------------------+ +-------------------+ +-------------------+
^ ^
| |
| |
+-------------------+ +-------------------+
| CheckingAccount | | SavingsAccount |
+-------------------+ +-------------------+
| + calculateInterest() | | + calculateInterest() |
+-------------------+ +-------------------+
```
#### **b. Java Code Implementation**
```java
// Account class (Superclass)
class Account {
private int accountNumber;
private double balance;
private String accountType;
public Account(int accountNumber, double balance, String accountType) {
this.accountNumber = accountNumber;
this.balance = balance;
this.accountType = accountType;
}
public void deposit(double amount) {
balance += amount;
public void withdraw(double amount) {
if (amount <= balance) {
balance -= amount;
} else {
System.out.println("Insufficient balance");
public double getBalance() {
return balance;
// SavingsAccount class (Subclass of Account)
class SavingsAccount extends Account {
private double interestRate = 0.03; // 3% annual interest
public SavingsAccount(int accountNumber, double balance) {
super(accountNumber, balance, "Savings");
public void calculateInterest() {
double interest = getBalance() * interestRate;
deposit(interest);
}
// CheckingAccount class (Subclass of Account)
class CheckingAccount extends Account {
public CheckingAccount(int accountNumber, double balance) {
super(accountNumber, balance, "Checking");
// Customer class
class Customer {
private int customerID;
private String name;
private String address;
private String phone;
private Account[] accounts;
public Customer(int customerID, String name, String address, String phone) {
this.customerID = customerID;
this.name = name;
this.address = address;
this.phone = phone;
this.accounts = new Account[2]; // Assuming a customer can have 2 accounts
public void addAccount(Account account) {
for (int i = 0; i < accounts.length; i++) {
if (accounts[i] == null) {
accounts[i] = account;
break;
public void displayAccounts() {
for (Account account : accounts) {
if (account != null) {
System.out.println("Account Number: " + account.getBalance());
// Main class
public class OnlineBankingSystem {
public static void main(String[] args) {
Customer customer = new Customer(1, "John Doe", "123 Main St", "555-1234");
SavingsAccount savingsAccount = new SavingsAccount(101, 1000);
CheckingAccount checkingAccount = new CheckingAccount(102, 500);
customer.addAccount(savingsAccount);
customer.addAccount(checkingAccount);
savingsAccount.deposit(200);
savingsAccount.calculateInterest();
System.out.println("Savings Account Balance: " + savingsAccount.getBalance());
checkingAccount.withdraw(100);
System.out.println("Checking Account Balance: " + checkingAccount.getBalance());
```
---
### **How to Convert to PDF**:
1. Copy the above content.
2. Paste it into a Word document or Google Docs.
3. Save the document as a PDF.
Let me know if you need further assistance!