TY - Lab-III CS-359 Core JAVA Slip (Rev 2021-22)
TY - Lab-III CS-359 Core JAVA Slip (Rev 2021-22)
Q1) Write a Program to print all Prime numbers in an array of ‘n’ elements.
(use command line arguments)
[10 marks]
Q2) Define an abstract class Staff with protected members id and name. Define a parameterized
constructor. Define one subclass OfficeStaff with member department. Create n objects of
OfficeStaff and display all details.
[20 marks]
Slip 1
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Write a program to accept ‘n’ name of cities from the user and sort them in ascending order
[10 marks]
Slip 2
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Write a program to accept ‘n’ name of cities from the user and sort them in ascending
order.
[10 marks]
[20 marks]
Slip 3
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Write program to define class Person with data member as Personname,Aadharno,
Panno. Accept information for 5 objects and display appropriate information (use
this keyword).
[10 marks]
Q2) Write a Java program to create a Package “SY” which has a class SYMarks (members –
ComputerTotal, MathsTotal, and ElectronicsTotal). Create another package TY which has
a class TYMarks (members – Theory, Practicals). Create ‘n’ objects of Student class
(having rollNumber, name, SYMarks and TYMarks). Add the marks of SY and TY
computer subjects and calculate the Grade (‘A’ for >= 70, ‘B’ for >= 60 ‘C’ for >= 50,
Pass Class for > =40 else‘FAIL’) and display the result of the student in proper format.
[20 marks]
Slip 4
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Write a program for multilevel inheritance such that Country is inherited from Continent.
State is inherited from Country. Display the place, State, Country and Continent.
[10 marks]
Q2) Write a program to accept a number from the user, if number is zero then throw user defined
exception “Number is 0” otherwise check whether no is prime or not (Use static keyword).
[20 marks]
Slip 5
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
[10 marks]
Q2) Create an abstract class “order” having members id, description. Create two subclasses
“PurchaseOrder” and “Sales Order” having members customer name and Vendor name
respectively. Definemethods accept and display in all cases. Create 3 objects each of Purchase
Order and Sales Order and accept and display details.
[20 marks]
Slip 6
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Design a class for Bank. Bank Class should support following operations;
a. Deposit a certain amount into an account
b. Withdraw a certain amount from an account
c. Return a Balance value specifying the amount with details
[10 marks]
Q2) Write a program to find the Square of given number using function interface.
[20 marks]
Slip 7
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Create a class Sphere, to calculate the volume and surface area of sphere.
(Hint : Surface area=4*3.14(r*r), Volume=(4/3)3.14(r*r*r))
[10 marks]
Q2) Write a program to create a super class Vehicle having members Company and price. Derive two
different classes LightMotorVehicle(mileage) and HeavyMotorVehicle (capacity_in_tons). Accept the
information for "n" vehicles and display the information in appropriate form. While taking data, ask
user about the type of vehicle first.
[20 marks]
Slip 8
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q2) Write a program to using marker interface create a class Product (product_id, product_name,
product_cost, product_quantity) default and parameterized constructor. Create objectsof class
product and display the contents of each object and Also display the object count.
[20 marks]
Slip 9
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Write a program to find the cube of given number using functional interface.
[10 marks]
Q2) Write a program to create a package name student. Define class StudentInfo with method to
display information about student such as rollno, class, and percentage. Create another class
StudentPer with method to find percentage of the student. Accept student details like
rollno, name, class and marks of 6 subject from user.
[20 marks]
Slip 10
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) 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.
[10 marks]
Q2) Write a program to accept the username and password from user if username and password are
not same then raise "Invalid Password" with appropriate msg.
[20 marks]
Slip 11
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Write a program to create parent class College(cno, cname, caddr) and derived class
Department(dno, dname) from College. Write a necessary methods to display College details.
[10 marks]
[20 marks]
Slip 12
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Write a Program to illustrate multilevel Inheritance such that country is inherited from
continent. State is inherited from country. Display the place, state, country and continent.
[10 marks]
Q2) Addition has two methods add () and subtract (), which are used to add two integers and
subtract two, float values respectively. Maximum has a method max () to display the
maximum of two integers
[20 marks]
Slip 13
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
[10 marks]
Q2) Write a Java program to create a Package “SY” which has a class SYMarks (members –
ComputerTotal, MathsTotal, and ElectronicsTotal). Create another package TY which has a
class TYMarks (members – Theory, Practicals). Create ‘n’ objects of Student class (having
rollNumber, name, SYMarks and TYMarks). Add the marks of SY and TY computer subjects
and calculate the Grade (‘A’ for >= 70, ‘B’ for >= 60 ‘C’ for >= 50, Pass Class for > =40
else‘FAIL’) and display the result of the student in proper format.
[20 marks]
Slip 14
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Define an Employee class with suitable attributes having getSalary() method, which returns
salary withdrawn by a particular employee. Write a class Manager which extends a class
Employee, override the getSalary() method, which will return salary of manager by adding
traveling allowance, house rent allowance etc.
[10 marks]
Q2) Write a program to define a class Account having members custname, accno. Define default
and parameterized constructor. Create a subclass called SavingAccount with member
savingbal, minbal. Create a derived class AccountDetail that extends the class SavingAccount
with members, depositamt and withdrawalamt. Write a appropriate method to display customer
details.
[20 marks]
Slip 15
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Write a program to find the Square of given number using function interface.
[10 marks]
Q2 Define a class ‘Donor’ to store the below mentioned details of a blood donor. name, age,
address, contactnumber, bloodgroup, date of last donation. Create ‘n’ objects of this class for
all the regular donors at Pune. Write these objects to a file. Read these objects from the file and
display only those donors’ details whose blood group is ‘A+ve’ and had not donated for the
recent six months.
[20 marks]
Slip 16
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Design a Super class Customer (name, phone-number). Derive a class Depositor(accno , balance)
from Customer. Again, derive a class Borrower (loan-no, loan-amt) from Depositor. Write
necessary member functions to read and display the details of ‘n’customers.
[10 marks]
Q2) Create an abstract class 'Bank' with an abstract method 'getBalance'. Rs.100, Rs.150 and
Rs.200 are deposited in banks A, B and C respectively. 'BankA', 'BankB' and 'BankC' are
subclasses of class 'Bank', each having a method named 'getBalance'. Call this method by
creating an object of each of the three classes.
[20 marks]
Slip 17
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Define a class MyNumber having one private int data member. Write a default constructor to
initialize it to 0 and another constructor to initialize it to a value (Use this). Write methods isNegative,
isPositive, isZero, isOdd, isEven. Create an object in main.Use command line arguments to pass a value
to the Object.
[10 marks]
Slip 18
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Create an abstract class 'Bank' with an abstract method 'getBalance'. Rs.100, Rs.150 and
Rs.200 are deposited in banks A, B and C respectively. 'BankA', 'BankB' and 'BankC' are
subclasses of class 'Bank', each having a method named 'getBalance'. Call this method by
creating an object of each of the three classes.
[10 marks]
Q2) Define a class MyNumber having one private int data member. Write a default constructor to
initialize it to 0 and another constructor to initialize it to a value (Use this). Write methods
isNegative, isPositive, isZero, isOdd, isEven. Create an object in main.Use command line
arguments to pass a value to the Object
[20 marks]
Slip 19
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Write a Program to illustrate multilevel Inheritance such that country is inherited from
continent. State is inherited from country. Display the place, state, country and continent.
[10 marks]
Q2) Write a package for Operation, which has two classes, Addition and Maximum. Addition
has two methods add () and subtract (), which are used to add two integers and subtract two,
float values respectively. Maximum has a method max () to display the maximum of two
integers
[20 marks]
Slip 20
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Define a class MyNumber having one private int data member. Write a default constructor to
initialize it to 0 and another constructor to initialize it to a value (Use this). Write methods
isNegative, isPositive, isZero, isOdd, isEven. Create an object in main.Use command line
arguments to pass a value to the Object.
[10 marks]
[20 marks]
Slip 21
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Write a program to create an abstract class named Shape that contains two integers and an
empty method named printArea(). Provide three classes named Rectangle, Triangle and
Circle such that each one of the classes extends the class Shape. Each one of the classes
contain only the method printArea() that prints the area of the given shape. (use method
overriding).
[10 marks]
Q2) Define an abstract class Staff with protected members id and name. Define a parameterized
constructor. Define one subclass OfficeStaff with member department. Create n objects of OfficeStaff
[20 marks]
Slip 22
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Define a class MyNumber having one private int data member. Write a default constructor to
initialize it to 0 and another constructor to initialize it to a value (Use this). Write methods
isNegative, isPositive, isZero, isOdd, isEven. Create an object in main.Use command line
arguments to pass a value to the Object.
[10 marks]
[20 marks]
Slip 23
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Create an abstract class 'Bank' with an abstract method 'getBalance'. Rs.100, Rs.150 and
Rs.200 are deposited in banks A, B and C respectively. 'BankA', 'BankB' and 'BankC'
are subclasses of class 'Bank', each having a method named 'getBalance'. Call this method
by creating an object of each of the three classes.
[10 marks]
[20 marks]
Slip 24
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Write a program for multilevel inheritance such that Country is inherited from Continent. State
is inherited from Country. Display the place, State, Country and Continent.
[10 marks]
Q2) Design a class for Bank. Bank Class should support following operations;
a. Deposit a certain amount into an account
b. Withdraw a certain amount from an account
c. Return a Balance value specifying the amount with details [20 marks]
Slip 25
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Define a Item class (item_number, item_name, item_price). Define a default and parameterized
constructor. Keep a count of objects created. Create objects using parameterized constructor
and display the object count after each object is created.(Use static member and method). Also
display the contents of each object.
[10 marks]
Q2) Define a class ‘Donor’ to store the below mentioned details of a blood donor. name, age,
address, contactnumber, bloodgroup, date of last donation. Create ‘n’ objects of this class for
all the regular donors at Pune. Write these objects to a file. Read these objects from the file
and display only those donors’ details whose blood group is ‘A+ve’ and had not donated for
the recent six months.
[20 marks]
Slip 26
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Define an Employee class with suitable attributes having getSalary() method, which returns
salary withdrawn by a particular employee. Write a class Manager which extends a class
Employee, override the getSalary() method, which will return salary of manager by adding
traveling allowance, house rent allowance etc.
[10 marks]
Q2) Write a program to using marker interface create a class Product (product_id, product_name,
product_cost, product_quantity) default and parameterized constructor. Create objectsof class
product and display the contents of each object and Also display the object count.
[20 marks]
Slip 27
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Write a program to create a package name student. Define class StudentInfo with method to
display information about student such as rollno, class, and percentage. Create another class
StudentPer with method to find percentage of the student. Accept student details like rollno,
name, class and marks of 6 subject from user.
[10 marks]
Q2) 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.
[20 marks]
Slip 28
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
[10 marks]
Q2) Write a program to create a super class Vehicle having members Company and price.
Derive two different classes LightMotorVehicle(mileage) and HeavyMotorVehicle
(capacity_in_tons). Accept the information for "n" vehicles and display the information in
appropriate form. While taking data, ask user about the type of vehicle first.
[20 marks]
Slip 29
Savitribai Phule Pune University
T.Y.B.Sc. Computer Science Practical Examination
SEMESTER – V
Course Code CS – 359
Practical Course based on CS 355(Core Java)
Duration: 3 Hours Maximum Marks: 35
Q1) Write program to define class Person with data member as Personname,Aadharno, Panno.
Accept information for 5 objects and display appropriate information (use this keyword).
[10 marks]
Q2) Create an abstract class “order” having members id, description. Create two subclasses
“PurchaseOrder” and “Sales Order” having members customer name and Vendor name
respectively. Definemethods accept and display in all cases. Create 3 objects each of
Purchase Order and Sales Order and accept and display details.
[20 marks]
Slip 30