/WT-LAB-09

Programs on Abstract Classes , Interfaces, Packages , String Handling

Primary LanguageJava

WT-LAB-09

Programs on Abstract Classes , Interfaces, Packages , String Handling

Questions:-

1. Illustrate the usage of abstract class with following Java classes –
i>An abstract class „student‟ with data member roll no, reg no and a abstract method course()
ii>A subclass „kiitian‟ with course() method implementation

2. Define an interface Motor with a data member –capacity and two methods such as run() and consume(). Define a Java class „Washing machine‟ which implements this interface and write the code to check the value of the interface data member thru an object of the class.

3. Define an interface with three methods – earnings(), deductions() and bonus() and define a Java class „Manager‟ which uses this interface without implementing bonus() method. Also define another Java class „Substaff‟ which extends from „Manager‟ class and implements bonus() method. Write the complete program to find out earnings, deduction and bonus of a sbstaff with basic salary amount entered by the user as per the following guidelines –

earnings --> basic + DA (80% of basic) + HRA (15% of basic)
deduction --> PF 12% of basic
bonus --> 50% of basic

4. Define two packages as – General and Marketing. In General package define a class „employee‟ with data members as empid(protected), ename(private) and a public method as earnings() which calculate total earnings as

earnings --> basic + DA (80% of basic) + HRA (15% of basic)

In Marketing package define a class „sales‟ which is extending from „employee‟ class and has a method tallowance() which calculates Travelling Allowance as 5% of total earning. Write the programs to find out total earning of a sales person for the given basic salary amount and print along with the emp id.

5. Write a program to perform following operations on user entered strings –
i) Change the case of the string
ii) Reverse the string
iii) Compare two strings
iv) Insert one string into another string