0% found this document useful (0 votes)
73 views2 pages

Module 3 2

The document describes 10 programming assignments involving object-oriented concepts in Java like inheritance, polymorphism, abstraction, and exception handling. Some key tasks include: 1) Create an Employee class and Manager class that inherits from Employee, overriding the computeSalary() method. 2) Write a program to perform integer division that throws exceptions if the numbers are non-integers or the second number is zero. 3) Create classes to store student personal and mark details, inheriting properties to calculate average marks. The assignments involve concepts like inheritance, abstraction, polymorphism, packages, exception handling, and working with arrays and lists.

Uploaded by

Historian Famous
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
73 views2 pages

Module 3 2

The document describes 10 programming assignments involving object-oriented concepts in Java like inheritance, polymorphism, abstraction, and exception handling. Some key tasks include: 1) Create an Employee class and Manager class that inherits from Employee, overriding the computeSalary() method. 2) Write a program to perform integer division that throws exceptions if the numbers are non-integers or the second number is zero. 3) Create classes to store student personal and mark details, inheriting properties to calculate average marks. The assignments involve concepts like inheritance, abstraction, polymorphism, packages, exception handling, and working with arrays and lists.

Uploaded by

Historian Famous
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 2

ASSIGNMENT III

1) Write a JAVA program to get the details of the Employees


of a company (Use employee class). Create another class
called Manager which inherits the features of Employee
class. Implement the concept of overriding for the
method computeSalary() which is present in both the
classes. Use setter and getter methods to set values and
get values.
• HRA=10% of basic pay
• DA=73% of basic pay
• Gross pay=basic pay+DA+HRA
• Income tax=30% of gross pay
• net salary= Gross pay-income tax

2) Write a program to perform integer divisions. The user


enters two numbers Num1 and Num2. The division of Num1
and Num2 is displayed . If Num1 or Num2 were not an
integer, the program would throw Number Format
Exception. If Num2 is Zero, the program would throw an
Arithmetic Exception.
3) Write a JAVA program with the class name “one” and “two”
to get the personal and mark details of a student
respectively and create a class “three” that inherits
the properties of “one” and “two” to calculate the
average mark obtained by that student. (Use Super
keyword to access the variables and methods in super
class)
4) Write a class Reservation that allow you to book a
person on a holiday. Get the details of the persons
(Name, age, place of visit). Print the bill. Use two
packages „allot‟ and „display‟. „allot‟ has the class
Reservation and „display‟ has the class Print.
printBill() is defined in the Reservation class and it
prints the bill. printBill() method should be called
from Print class
5) Write a JAVA program with a class named as “circle” that
implements an interface named as “circleinterface” and
define the methods named as “area” and “circum” in the
class to find the area and circumference of the circle
6) Calculate the area of a rectangle, a square and a
circle. Create an abstract class 'Shape' with three
abstract methods namely 'RectangleArea' taking two
parameters, 'SquareArea' and 'CircleArea' taking one
parameter each. The parameters of 'RectangleArea' are
its length and breadth, that of 'SquareArea' is its side
and that of 'CircleArea' is its radius. Now create
another class 'Area' containing all the three methods
'RectangleArea', 'SquareArea' and 'CircleArea' for
printing the area of rectangle, square and circle
respectively. Create an object of class 'Area' and call
all the three methods.
7) Write a Java program to create a new array list with
EmpID and EmpName and perform the following operations
• Iterate through all elements in a array list
• Retrieve an Employee name at position 5
• Remove the fourth Employee from the array list
• Copy one array list into another
• Extract a portion of a array list
• Compare two array lists
• Empty an array list
• Get the first and last occurrence of the
specified Employee in a linked list

8) Create the following packages and classes

PACKAGE NAME CLASS NAME


mygame.server Server
mygame.shared Utilities
mygame.client Client

Declare variables INIT, SCORE in Utilities class and


increament the score of the game user using a method
computeScore() in the class Client. Call the method
computeScore() from Server class and print the score.

9) Write a java program to handle array out of bounds


exception while storing and retrieving an array of
student marks
10) Using the Account class as a base class, write two
derived classes called SavingsAccount and
CurrentAccount. A SavingsAccount object, in addition to
the attributes of an Account object, should have an
interest variable and a method which adds interest to
the account. A CurrentAccount object, in addition to the
attributes of an Account object, should have an
overdraft limit variable. Ensure that you have
overridden methods of the Account class as necessary in
both derived classes. Now create a Bank class, an object
of which contains an array of Account objects. Accounts
in the array could be instances of the Account class,
the SavingsAccount class, or the CurrentAccount class.
Create some test accounts (some of each type).Write an
update method in the bank class. It iterates through
each account, updating it in the following ways: Savings
accounts get interest added (via the method you already
wrote); CurrentAccounts get a letter sent if they are in
overdraft. The Bank class requires methods for opening
and closing accounts, and for paying a dividend into
each account.
[Make sure all types of inheritance are implemented for
the above scenario]

You might also like