TYBCS Java Assignment 3 - Sem I

SET A

1.  Define a class Employee having private members – id, name, department, salary. Define default and parameterized constructors. Create a subclass called “Manager” with private member bonus. Define methods accept and display in both the classes. Create n objects of the Manager class and display the details of the manager having the maximum total salary (salary+bonus)   

2. Create an abstract class Shape with methods calc_area and calc_volume. Derive three classes Sphere(radius) , Cone(radius, height) and Cylinder(radius, height), Box(length, breadth, height) from it. Calculate area and volume of all. (Use Method overriding). 

3. Write a Java program to create a super class Vehicle having members Company and price. Derive 2 different classes LightMotorVehicle (members – mileage) and HeavyMotorVehicle (members – capacity-in-tons). Accept the information for n vehicles and display the information in appropriate form. While taking data, ask the user about the type of vehicle first. 

SET B

1. Define an abstract class “Staff” with members name and address. Define two sub-classes of this class – “FullTimeStaff” (department, salary) and “PartTimeStaff” (number-of-hours, rate-perhour).  Define appropriate constructors. Create n objects which could be of either FullTimeStaff or PartTimeStaff class by asking the user’s choice. Display details of all “FullTimeStaff” objects and all “PartTimeStaff” objects. 

Post a Comment

5 Comments

  1. Replies
    1. ha na...jaldi se upload karo..aaj last date hain..

      Delete
  2. Slip11_1: Define an interface “Operation” which has method volume( ).Define a constant PI
    having a value 3.142 Create a class cylinder which implements this interface (members –
    radius,height). Create one object and calculate the volume.
    import java.io.*;
    interface Operation
    {
    final static float pi=3.142f;
    void area();
    void volume();
    }
    class Cylinder implements Operation
    {
    double radius,height;
    void input() throws Exception
    {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    System.out.print("\n Enter the radius and height=");
    radius=Double.parseDouble(br.readLine());
    height=Double.parseDouble(br.readLine());
    }
    public void area()
    {
    double a=(2*pi*radius*height)+(2*pi*radius*radius);
    System.out.println("the area of cylinder is " +a);
    }
    public void volume()
    {
    double v=pi*radius*radius*height;
    System.out.println("the volume of cylinder is "+v);
    }
    }
    class slipno11a
    {
    public static void main(String args[]) throws Exception
    {
    Cylinder C1=new Cylinder();
    C1.input();
    C1.area();

    C1.volume();
    }
    }
    Slip11_2:

    ReplyDelete
  3. This is correct program

    ReplyDelete