MCS-024 Solved Assignment 2024-25 | learningscience.co.
in 1
Course Code : MCS-024
Course Title : Object Oriented Technologies and Java Programming
Assignment Number : BCA (IV)/024/Assignment/2024-25
Maximum Marks : 100%
Last Date of Submission : 31st October, 2024 (For July session) 30th April, 2025 (For January session)
Note:
There are Three questions in this assignment which carry 80 marks, in total. Rest 20 marks are for viva-
voce. Answer all the questions. Give appropriate comments in programs to increase understandability.
Wherever required, you may write java program, run it on machine and take its output as part of
solution. Please go through the guidelines regarding assignments given in the Programme Guide for the
format of presentation.
Q1: Give an example of a Project that is suitable for application of Procedural Programming rather
than Object Oriented Programming. Justify your answer point wise in detail. (30 marks)
Solution:
I believe a simple text-based calculator would be a suitable project for procedural programming,
rather than object-oriented programming.
Reasons:
Firstly, a calculator's function is all about a sequence of steps. You take input from the user, like
numbers and what operation to perform. Then you do the calculations based on those inputs, and
finally display the result. This step-by-step process aligns perfectly with the structure of procedural
programming.
Secondly, a simple calculator doesn't need complicated data structures like classes and objects. We
can just use a few variables to store the numbers, the chosen operation, and the final answer. This
keeps things simple and efficient.
Thirdly, the logic for each operation (addition, subtraction, multiplication, division) is pretty
straightforward and self-contained. We don't need to reuse these operations in a complex way.
Procedural programming's focus on functions makes it easy to separate these operations clearly.
Finally, for a small project like this, procedural programming is much simpler to implement and
understand. It often leads to more efficient code because we don't have the overhead of creating
and managing objects.
MCS-024 Solved Assignment 2024-25 | learningscience.co.in 2
So, in this case, the advantages of procedural programming outweigh the benefits of object-oriented
programming. It's a good example of how a more structured approach might not be necessary for
simpler projects.
Taking an example, imagine we're building a basic calculator. In procedural programming, we would:
1. Get Input: We'd ask the user to enter two numbers and store them in variables.
2. Choose Operation: We'd then ask the user to choose an operation (like "add", "subtract",
etc.) and store that choice in a variable.
3. Perform Calculation: Based on the operation chosen, we'd use different sections of code to
perform the calculation (like adding the two numbers if they chose "add").
4. Display Output: Finally, we'd show the user the result of the calculation.
This linear flow of steps is natural in procedural programming.
In contrast, using object-oriented programming might involve creating a "Calculator" class with
separate methods for each operation. This would add complexity without offering much advantage
for a simple calculator.
So we can say, while object-oriented programming is great for large, modular projects, procedural
programming is ideal for simple tasks that require a clear, sequential flow of steps and minimal
data structures. A simple calculator is a perfect example of this.
Q2: Give an example of a Project that is suitable for application of Object Oriented Programming
rather than Procedural Programming. Justify your answer point wise in detail. (30 marks)
Solution:
I think a good example of a project that really benefits from object-oriented programming (OOP)
over procedural programming would be a "Graphical Game".
Reasons are the following:
1. Complex Objects: Games usually have lots of different things in them: characters, enemies,
items, levels, etc. Each of these is a complex object with its own properties and behavior.
OOP lets us model these things as classes, making the code very organized.
2. Encapsulation and Reusability: OOP allows us to group data (like a character's position and
health) and actions (like moving, attacking, or interacting with items) together in a class. This
keeps things tidy and helps us reuse the same character logic for different characters in the
game.
3. Inheritance: OOP's inheritance lets us create relationships between objects. For example,
we could have a base Character class and then inherit from it to create specific types like
PlayerCharacter, Enemy, or NonPlayerCharacter. This helps us reuse common character
features and add unique abilities for each type.
MCS-024 Solved Assignment 2024-25 | learningscience.co.in 3
4. Polymorphism: OOP's polymorphism lets us write code that works with different kinds of
objects in a unified way. Imagine a method called interact(). We could use it for both the
PlayerCharacter and Enemy classes without having to write separate code for each. This
makes the code much more flexible.
5. Easier to Maintain: As games get more complex, OOP makes it easier to manage and
update the code. Changing how a character moves or attacks only needs to be done in the
Character class, and all the other character types will automatically inherit the changes.
Example:
Let us consider we have a Character class in Java:
public class Character {
private int health;
private int positionX;
private int positionY;
public Character(int health, int positionX, int positionY) {
this.health = health;
this.positionX = positionX;
this.positionY = positionY;
}
public void move(int newX, int newY) {
this.positionX = newX;
this.positionY = newY;
}
// Other methods like attack(), interact(), etc.
}
We can then create different character types by inheriting from Character:
public class PlayerCharacter extends Character {
// Special player features
}
public class Enemy extends Character {
// Special enemy features
}
Therefore, a graphical game is a perfect example of a project where OOP shines. Its ability to handle
complex objects, encourage reusability, and provide flexibility makes it a powerful tool for game
development.
MCS-024 Solved Assignment 2024-25 | learningscience.co.in 4
Procedural programming, while suitable for simpler tasks, would struggle to manage the complexity
and interconnectedness of a modern game.
Q3: Give an example of a Project that is suitable for application of Object Oriented Programming
and usage of Java Programming Language rather than any other Object Oriented Programming
Language. Justify your answer point wise in detail. (20 marks)
Solution:
I think a "Library Management System" would be a great example of a project that's perfect for
object-oriented programming (OOP) using Java.
Reasons are the following:
1. Real-World Objects: A library has many real-world objects like books, members, librarians,
and borrowing records. OOP lets us model these things directly using classes. For example,
we can have a Book class with properties like title, author, and ISBN. This makes the code
more intuitive and organized.
2. Encapsulation and Data Hiding: OOP allows us to bundle data (like a book's details) and
methods (like functions to borrow or return a book) together inside a class. This keeps the
data safe and prevents accidental changes, which is important in a library system.
3. Inheritance: We can use inheritance to create relationships between different objects. For
example, we could have a Member class and different sub-classes like StudentMember and
FacultyMember. This would allow us to reuse common member features and add specific
features for each type of member.
4. Polymorphism: OOP lets us write code that works with different types of objects in a unified
way. Imagine a method to "check out" a book. It can work with any kind of Member (student
or faculty) without needing separate code for each. This makes the code more flexible and
easier to maintain.
5. Java's Strengths: Java is a mature, widely-used OOP language with a vast ecosystem of
libraries and frameworks. It's a good choice for this project because it has great support for
database connectivity (to store book and member information), GUI development (for a
user-friendly interface), and networking (if we need to share the system across multiple
computers).
Example:
Taking an example of a Book class in Java:
public class Book {
private String title;
private String author;
private String ISBN;
public Book(String title, String author, String ISBN) {
MCS-024 Solved Assignment 2024-25 | learningscience.co.in 5
this.title = title;
this.author = author;
this.ISBN = ISBN;
}
// Getters and setters for title, author, and ISBN
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getISBN() {
return ISBN;
}
public void setISBN(String ISBN) {
this.ISBN = ISBN;
}
}
We have private data (title, author, ISBN) and a constructor to create Book objects. Using getters
and setters, we can access and modify the data in a controlled way.
So we can say, a library management system is a perfect example of a project that utilizes all the
benefits of object-oriented programming. Java's strong support for OOP features and rich ecosystem
make it a great choice for developing such a system.