OOPM Assi 1to6
OOPM Assi 1to6
P ractical Assignments
FY CS / IT Sem - 2
PRACTICAL ASSIGNMENT - 6
Week : 3rd - 8th March,2025
Aim :Implementing Hierarchical Inheritance
Create following classes and relationships with their respective data members.
PRACTICAL ASSIGNMENT - 5
Week : 24th Feb - 1st March,2025
Aim :Implementing Multilevel Inheritance
2. Using an array of objects, add and display data of at least 3 Under Graduate Students.
Input the values of student’s name, phone number, email address, enrollment number,
course and total marks scored.
[NOTE : CGPA should not be input, but must be calculated using calcCGPA]
[CGPA = TotalMarks x 10 / 500 , TotalMarks should be from 0 to 500 only]
PRACTICAL ASSIGNMENT - 4
Week : 3rd-15th February,2025
Aim :Implementing Simple Inheritance
SIMPLE
Create the class called“Customer”as follows withgiven accessibility for its members:
ata member:
D
+Name
+Age
+Contact
MODERATE
Class: Customer
ata member:
D
+Name
+Age
+Contact
↑
Class: Account
ata members:
D
+Accno
+Balance
ember functions:
M
*deposit(double amt)
*withdraw(double amt)
*transfer(Account a1, Account a2, double amt)
*s howCustomers() : method to display all customers
Menu options :
E xpected Output:
Name Age Contact Number Account Number Balance
_________________________________________________________________
Peter Andrews 30 4478962586 111 20000
Emma Stone 30 3456345675 222 30000
(Show details of n customers )
ADVANCED
1) Allow the user todepositsome amount in the account.Display the reflected balance in
the account after the transaction.
Expected Input:
Enter AccountNo: 111
Enter the amount you wish to deposit: 10000
Expected Output:
Transaction Successful!
AccountNo: 111
Final balance: 30000
2) Allow the user towithdrawsome amount from the account;only if the withdrawal
amount is less than the account balance, otherwisethrow an exception. Display the final
balance in the account after the transaction.
Expected Input:
Enter AccountNo: 111
Enter the amount you wish to withdraw: 40000
Expected Output:
Sorry! You don’t have a sufficient balance in your account.
E xpected Input:
Enter AccountNo: 111
Enter the amount you wish to withdraw: 10000
Expected Output:
Transaction Successful!
AccountNo: 111
Final balance: 10000
3) Allow the user totransfersome amount from his accountto another account;only if the
transfer amount is less than the account balance,otherwise throw an exception. Display
the final balance of both accounts after the transaction.
Expected Input:
Enter your AccountNo: 111
Enter AccountNo you wish to transfer: 222
Enter the amount you wish to transfer: 30000
Expected Output:
Sorry! You don’t have a sufficient balance in your account.
E xpected Input:
Enter your AccountNo: 111
Enter AccountNo you wish to transfer: 222
Enter the amount you wish to transfer: 10000
Expected Output:
Transaction Successful!
AccountNo: 111 Balance: 10000
AccountNo: 222 Balance: 40000
PRACTICAL ASSIGNMENT - 3
Week : 27th Jan - 1st Feb,2025
Aim :Implementing Exception Handling
PART 1
1. Write a program in Java to accept two numbers from the user. Raise the
ArithmeticExceptionwhen the user tries to dividenum1 by num2, and num2 is zero.
2. Write a java program which accepts the elements of an integer array of sizen, and displays
the same. Catch theArrayIndexOutOfBoundsExceptionwhenever the user tries to access
the array outside of its bound (range).
PART 2
reate the following exceptions, with reference to the Student class created in previous
C
assignments:
1. If the user tries to input a String value for the s_id, throw theInputMismatchException
and print the message“Invalid Input !”in the catchblock.
2. If the user enters total_marks less than zero or greater than 500, throw a user-defined
exception named“InvalidMarksException”.
3. Finally, print the message“Student details entered!”,regardless of if any exception is
raised or not.
S ELF REFERENCE
rocess of Exception Handling :
P
E xample :
Suppose you’re writing a program where a user inputs his age to determine the eligibility to vote.
Throw an exception when his age is under 18.
Handling exception :
PRACTICAL ASSIGNMENT - 2
Week : 1st-4th January,2025
Aim :Implementing data hiding & getter and settermethods.
Working with array of objects.
PART 1
1. Implement data hiding for theStudentclass earliercreated inAssignment-1.
[make all attributes private.]
2. Create respective getter and setter methods for all attributes.
[make all getter-setter methods public so that attributes can be accessed outside the class.]
. Now, initialize the instance variables of objects using the common setter method.
3
4. Print the student attributes using their respective getter methods.[in tabular format]
PART 2
1. Using the Student class, create and initialize an array of objects of size 2.
Print the details of all students.[Use Static values]
2. Implement another array of objects of sizenusinguser input values.
Print the details of all students.[Use Dynamic values]
PRACTICAL ASSIGNMENT - 1
Week : 23rd-28th December,2024
Aim :Working with classes, objects and constructors
Student
s _id
s_name
dob
dept
total_marks(out of 500)
perc
If the default constructor is used, then thedeptvalue must be set to“IT”.
ThecalcPerc()method is used to calculate the percentage,based on total_marks input by
the user.
TheisEligibleToEnroll()method will print “Eligible”if the percentage is above 65, else it
will print “Not Eligible”.
Enter values for at least 3 students and print the details in a tabular form.
PRACTICAL ASSIGNMENT - 0
Week : 16th-21st December,2024
Aim :Introduction to OOP & revisiting Java Fundamentals
1. Create a user defined class namedArea. It shouldcontain the following methods:
circle() :to print area of a circle
square() :to print area of a square
triangle() :to print area of a triangle
[NOTE :define PI as a final variable(constant)in Area class]
Create an object, initialize necessary parameters within the concerned methods, and print
the area of all shapes in output.
t ype
colour
brand
price
reate at least 2 different objects of Pen class, setting different attributes for them and
C
print their details.
num[]
Create at least 2 different objects of the ArraySum class and print the sum of each.