Professional Documents
Culture Documents
Oop PR
Oop PR
Practice Assignments
FY CS / IT Sem - 2
PRACTICE ASSIGNMENT - 5
Level: Basic
Q-1 Write a java program which has base class Student and a derived class named INTERNAL
which input marks of 3 subjects and calculate percentage and grade. Display Student result in
proper format.
Note: Input marks out of 70 (keep validations that user does not marks greater than 70 or
lesser than 0)
Grade is
Level: Moderate
Q-2 Write a java program which has base class Student , a derived class named MARKS AND
RESULT to input internal and external marks and calculate total marks , percentage and grade.
Display Student result in proper format.
//Note: Input marks out of 70 for Internal (keep validations that user does not marks greater
than 70 or lesser than 0)
Input marks out of 30 for External (keep validations that user does not marks greater than 30 or
lesser than 0)
Level: Advanced
Q-3 Perform above Q-2 program for 10 students of the college in the proper format.
PRACTICE ASSIGNMENT - 4
PRACTICE ASSIGNMENT - 3
To implement Inheritance by developing a java program with Employee class with Emp_name,
Emp_id, Address, Mail_id, Mobile_no as members.
Inherit the classes, Programmer, Assistant Professor, Associate Professor and Professor from
employee class.
Add Basic Pay (BP) as the member of all the inherited classes with 97% of BP as DA, 10 % of BP as
HRA, 12% of BP as PF, 0.1% of BP for staff club fund.
Generate pay slips for the employees with their gross and net salary.
PRACTICE ASSIGNMENT - 2
PART - 1
Create a class named Pizza which stores information about a single pizza. The class contains
following members:
1. Private variables :
size – it can store values like small, medium, large
num_of_cheese_topping – it can take an integer value
PART - 2
1. Within set_num_of_cheese_topping(), if user enters string value for this field then,
print – “Error : Format mismatch” . Note: use InputMismatchException in catch.
2. If user enters any value which is equal to or less than zero then throw user defined
exception and print “Invalid number”.
3. Finally, whether exception is there or not in set_num_of_cheese_topping(), at the end
of the method you should print “Set method called”.
PRACTICE ASSIGNMENT - 1
PART - 1
Aim : Understanding how to reuse the same class for creating multiple objects
and storing multiple values. Implementing getter and setter methods.
EXAMPLE :
Creating objects :
Employee em1 = new Employee();
Employee em2 = new Employee();
PART - 2
Aim : Understanding object construction and destruction in JAVA.
Implementing different types of constructors.
1) Employee()
Prepared by: Prof. Lavleena Stephens
MAJOR-2 : Object Oriented Programming Methodology
Practice Assignments
FY CS / IT Sem - 2
2) Employee(EmpName)
3) Employee(EmpName, Gender, DOB, Dept, Salary)
B. When the default constructor is called, the Dept must be set to “IT” and Salary must be
initialized to “30000”.
C. When the second constructor is called, it should accept only EmpName as a parameter.
D. The third constructor should accept all the data member values as parameters.
E. Finally, use the getter method created in Assignment-3 and display the Employee details.
PART - 3
Aim : Implementing data hiding. Working with array of objects.
SOLUTION
PART - 1
2. Within the same class file, create the class Employee and add its data and members.
SAMPLE OUTPUT :
PART - 2
Prepared by: Prof. Lavleena Stephens
MAJOR-2 : Object Oriented Programming Methodology
Practice Assignments
FY CS / IT Sem - 2
1. Create the mentioned constructors in the same Employee class.
PART - 3