0% found this document useful (0 votes)
4 views

Assignment_2_OOP

The document outlines an assignment focused on Object-Oriented Programming, consisting of five tasks. These tasks include creating a base class 'Animal', implementing inheritance with a derived class 'Dog', demonstrating multiple inheritance with a second parent class 'Pet', encapsulating a 'BankAccount' class, and showcasing polymorphism with different classes implementing a common method. Each task emphasizes key OOP concepts such as inheritance, encapsulation, and polymorphism.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Assignment_2_OOP

The document outlines an assignment focused on Object-Oriented Programming, consisting of five tasks. These tasks include creating a base class 'Animal', implementing inheritance with a derived class 'Dog', demonstrating multiple inheritance with a second parent class 'Pet', encapsulating a 'BankAccount' class, and showcasing polymorphism with different classes implementing a common method. Each task emphasizes key OOP concepts such as inheritance, encapsulation, and polymorphism.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment 2: Object-Oriented Programming

### Task 1: Creating a Base Class

- Define a base class 'Animal' with a method 'speak' that prints 'Animal makes a sound'.

### Task 2: Inheritance and Method Overriding

- Create a derived class 'Dog' that inherits from 'Animal' and overrides 'speak' to print 'Woof!'.

### Task 3: Multiple Inheritance

- Implement a second parent class 'Pet' with an additional method.

- Have 'Dog' inherit from both 'Animal' and 'Pet'.

### Task 4: Encapsulation

- Create a class 'BankAccount' with private attributes for balance and methods to deposit and

withdraw money.

### Task 5: Polymorphism

- Create multiple classes (e.g., Dog, Cat) that implement a common method 'speak' differently.

Assignment 2: Object-Oriented Programming

### Task 1: Creating a Base Class

- Define a base class 'Animal' with a method 'speak' that prints 'Animal makes a sound'.

### Task 2: Inheritance and Method Overriding

- Create a derived class 'Dog' that inherits from 'Animal' and overrides 'speak' to print 'Woof!'.
### Task 3: Multiple Inheritance

- Implement a second parent class 'Pet' with an additional method.

- Have 'Dog' inherit from both 'Animal' and 'Pet'.

### Task 4: Encapsulation

- Create a class 'BankAccount' with private attributes for balance and methods to deposit and

withdraw money.

### Task 5: Polymorphism

- Create multiple classes (e.g., Dog, Cat) that implement a common method 'speak' differently.

Assignment 2: Object-Oriented Programming

### Task 1: Creating a Base Class

- Define a base class 'Animal' with a method 'speak' that prints 'Animal makes a sound'.

### Task 2: Inheritance and Method Overriding

- Create a derived class 'Dog' that inherits from 'Animal' and overrides 'speak' to print 'Woof!'.

### Task 3: Multiple Inheritance

- Implement a second parent class 'Pet' with an additional method.

- Have 'Dog' inherit from both 'Animal' and 'Pet'.

### Task 4: Encapsulation

- Create a class 'BankAccount' with private attributes for balance and methods to deposit and
withdraw money.

### Task 5: Polymorphism

- Create multiple classes (e.g., Dog, Cat) that implement a common method 'speak' differently.

Assignment 2: Object-Oriented Programming

### Task 1: Creating a Base Class

- Define a base class 'Animal' with a method 'speak' that prints 'Animal makes a sound'.

### Task 2: Inheritance and Method Overriding

- Create a derived class 'Dog' that inherits from 'Animal' and overrides 'speak' to print 'Woof!'.

### Task 3: Multiple Inheritance

- Implement a second parent class 'Pet' with an additional method.

- Have 'Dog' inherit from both 'Animal' and 'Pet'.

### Task 4: Encapsulation

- Create a class 'BankAccount' with private attributes for balance and methods to deposit and

withdraw money.

### Task 5: Polymorphism

- Create multiple classes (e.g., Dog, Cat) that implement a common method 'speak' differently.

Assignment 2: Object-Oriented Programming


### Task 1: Creating a Base Class

- Define a base class 'Animal' with a method 'speak' that prints 'Animal makes a sound'.

### Task 2: Inheritance and Method Overriding

- Create a derived class 'Dog' that inherits from 'Animal' and overrides 'speak' to print 'Woof!'.

### Task 3: Multiple Inheritance

- Implement a second parent class 'Pet' with an additional method.

- Have 'Dog' inherit from both 'Animal' and 'Pet'.

### Task 4: Encapsulation

- Create a class 'BankAccount' with private attributes for balance and methods to deposit and

withdraw money.

### Task 5: Polymorphism

- Create multiple classes (e.g., Dog, Cat) that implement a common method 'speak' differently.

You might also like