[go: up one dir, main page]

0% found this document useful (0 votes)
4 views1 page

Assignment - 3 Object Oriented Programming (PCC CS503)

Uploaded by

asish.off
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Assignment - 3 Object Oriented Programming (PCC CS503)

Uploaded by

asish.off
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Assignment - 3: Object Oriented Programming (PCC-CS503)

Write Java programs to solve the following problems-


1. Create a class Calculator
Use method overloading to implement a method calculate() with the following
variations:
calculate(int a, int b) – returns sum of two integers
calculate(double a, double b) – returns product of two double values
calculate(String s1, String s2) – returns concatenation of two strings
calculate(int[] arr) – returns the sum of elements in the integer array

2. Create a class Stack


Data Members: Integer array stack[], top
Constructor to initialize stack size, and top
Methods:
push() to insert elements
pop() to remove elements
display() to print the stack contents

3. Create a class Queue


Data Members: Integer array queue[], front, rear
Constructor to initialize queue size, front, rear
Methods:
enqueue() to add elements
dequeue() to remove elements
display() to print the queue elements

4. Create a super class Vehicle with


Data members: brand, model, and year.
Method displayVehicle() to show the details
Create two Sub-classes: Car and Bike
Car with additional fields: seatingCapacity, fuelType and a method displayCar()
Bike with additional fields: engineCapacity, isElectric and a method displayBike()
From main method accept details for one Car and one Bike from the user. Display their
complete details.

5. Create a super class Person with the following attributes and methods:
Attributes: name, age, gender
Methods: isAdult() – returns true if age ≥ 18
displayBasicInfo() – prints name, age, and gender
Create a derived class Employee with:
Attributes: employeeId, department, salary
Methods:
calculateBonus() – returns 10% of salary
displayEmployeeDetails() – uses displayBasicInfo() from Person and prints
all employee data

You might also like