TY - Lab-III CS-359 Core JAVA Slip (Rev 2021-22)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

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 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]

Q3) Viva [05 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 read the First Name and Last Name of a person, his weight and height using
command line arguments. Calculate the BMI Index which is defined as the individual's body mass
divided by the square of their height.
(Hint : BMI = Wts. In kgs / (ht)2)
[10 marks]

Q2) Define a class CricketPlayer (name,no_of_innings,no_of_times_notout, totatruns, bat_avg).


Create an array of n player objects .Calculate the batting average for each player using static
method avg(). Define a static sort method which sorts the array on the basis of average. Display
the player details in sorted order.
[20 marks]

Q3) Viva [05 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]

Q2) Define a class patient (patient_name, patient_age, patient_oxy_level,patient_HRCT_report).


Create an object of patient. Handle appropriate exception while patient oxygen level less than
95% and HRCT scan report greater than 10, then throw user defined Exception “Patient is Covid
Positive(+) and Need to Hospitalized” otherwise display its information.

[20 marks]

Q3) Viva [05 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 a program to print an array after changing the rows and columns of a given
two-dimensional array.
[10 marks]

Q2) Write a program to design a screen using Awt that will take a user name and password. If
the user name and password are not same, raise an Exception with appropriate message.
User can have 3 login chances only. Use clear button to clear the TextFields.
.
[20 marks]

Q3) Viva [05 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 menu driven program to perform the following operations on multidimensional array
ie matrices :
 Addition
 Multiplication
 Exit
[20 marks]

Q3) Viva [05 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

Q1) Write a program to display the Employee(Empid, Empname, Empdesignation, Empsal)


information using toString().

[10 marks]

Q2) Create an abstract class “order” having members id, description. Create two subclasses
“Purchase Order” and “Sales Order” having members customer name and Vendor name
respectively. Define methods accept and display in all cases. Create 3 objects each of Purchase
Order and Sales Order and accept and display details.

[20 marks]

Q3) Viva [05 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 accept a text file from user and display the contents of a file in
reverse order and change its case.
[20 marks]

Q3) Viva [05 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) Design a screen to handle the Mouse Events such as MOUSE_MOVED


and MOUSE_CLICKED and display the position of the Mouse_Click in a TextField.

[20 marks]

Q3) Viva [05 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

Q1) Define a “Clock” class that does the following ;


a. Accept Hours, Minutes and Seconds
b. Check the validity of numbers
c. Set the time to AM/PM mode
Use the necessary constructors and methods to do the above task
[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 objects of class
product and display the contents of each object and Also display the object count.
[20 marks]

Q3) Viva [05 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]

Q3) Viva [05 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]

Q3) Viva [05 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]

Q2) Write a java program that works as a simple calculator. Use a grid layout to arrange buttons for
the digits and for the +, -, *, % operations. Add a text field to display the result.
Simple Calculator

1 2 3 +
4 5 6 -
7 8 9 *

0 . = /

[20 marks]

Q3) Viva [05 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 accept a file name from command prompt, if the file exits then display
number of words and lines in that file.

[10 marks]

Q2) Write a program to display the system date and time in various formats shown below:
Current date is : 31/08/2021
Current date is : 08-31-2021
Current date is : Tuesday August 31 2021
Current date and time is : Fri August 31 15:25:59 IST 2021
Current date and time is : 31/08/21 15:25:59 PM +0530
[20 marks]

Q3) Viva [05 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

Q1) 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).

[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]

Q3) Viva [05 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) Accept the names of two files and copy the contents of the first to the second. First file having
Book name and Author name in file.

[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]

Q3) Viva [05 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) Write a program to design a screen using Awt that,

[20 marks]

Q3) Viva [05 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) Write Java program to design three text boxes and two buttons using swing. Enter different
strings in first and second textbox. On clicking the First command button, concatenation of
two strings should be displayed in third text box and on clicking second command button,
reverse of string should display in third text box

[20 marks]

Q3) Viva [05 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) Write a program to implement Border Layout Manager.

[10 marks]

Q2) Define a class CricketPlayer (name,no_of_innings,no_of_times_notout, totatruns, bat_avg).


Create an array of n player objects. Calculate the batting average for each player using static
method avg(). Define a static sort method which sorts the array on the basis of average.
Display the player details in sorted order.
[20 marks]

Q3) Viva [05 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) Write a program to accept the two dimensional array from user and display sum of its diagonal
elements.
[10 marks]

Q2) Write a program which shows the combo box which includes list of T.Y.B.Sc.(Comp. Sci)
subjects. Display the selected subject in a text field.
[20 marks]

Q3) Viva [05 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]

Q3) Viva [05 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 MyDate(Day, Month, year) with methods to accept and display a MyDateobject.
Accept date as dd,mm,yyyy. Throw user defined exception "InvalidDateException" if the date
is invalid.
[10 marks]

Q2) Create an employee class(id,name,deptname,salary). Define a default and parameterized


constructor. Use ‘this’ keyword to initialize instance variables. 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.

[20 marks]

Q3) Viva [05 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) Write a program that handles all mouse events and shows the event name at the center of the
Window, red in color when a mouse event is fired. (Use adapter classes).

[20 marks]

Q3) Viva [05 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]

Q2) Write a simple currency converter, as shown in the figure. User can enter the amount of
"Singapore Dollars", "US Dollars", or "Euros", in floating-point number. The converted
values shall be displayed to 2 decimal places. Assume that 1 USD = 1.41 SGD,
1 USD = 0.92 Euro, 1 SGD = 0.65 Euro.

[20 marks]

Q3) Viva [05 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]

Q2) Program that displays three concentric circles where ever the user clicks the mouse on a frame.
The program must exit when user clicks ‘X’ on the frame.

[20 marks]

Q3) Viva [05 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) Create a class Student(rollno, name ,class, per), to read student information from the console
and display them (Using BufferedReader class)
[10 marks]

Q2) Create the following GUI screen using appropriate layout manager. Accept the name, class,
hobbies from the user and display the selected options in a textbox.

[20 marks]

Q3) Viva [05 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]

Q3) Viva [05 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 accept a string as command line argument and check whether it is a file or
directory. Also perform operations as follows:
i)If it is a directory,delete all text files in that directory. Confirm delete operation from
user before deleting text files. Also, display a count showing the number of files deleted,
if any, from the directory.
ii)If it is a file display various details of that file.

[20 marks]

Q3) Viva [05 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 that reads on file name from the user, then displays information about
whether the file exists, whether the file is readable, whether the file is writable, the type of
file and the length of the file in bytes.

[10 marks]

Q2) Write a program called SwingTemperatureConverter to convert temperature values


between Celsius and Fahrenheit. User can enter either the Celsius or the Fahrenheit value,
in floating-point number. Hints: To display a floating-point number in a specific format
(e.g., 1 decimal place), use the static method String.format(), which has the same form
as printf(). For example, String.format("%.1f", 1.234) returns String "1.2".

[20 marks]

Q3) Viva [05 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

Q1) Write a program to create a class Customer(custno,custname,contactnumber,custaddr).


Write a method to search the customer name with given contact number and display the
details.

[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]

Q3) Viva [05 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) Write a program that creates a user interface to perform integer divisions. The user enters two
numbers in the text fields, Number1 and Number2. The division of Number1 and Number2 is
displayed in the Result field when the Divide button is clicked. If Number1 or Number2 were
not an integer, the program would throw a NumberFormatException. If Number2 were Zero,
the program would throw an Arithmetic Exception Display the exception in a message
dialog box.
[20 marks]

Q3) Viva [05 marks]

Slip 30

You might also like