0% found this document useful (0 votes)
81 views2 pages

Java Slipq 21-22

This document contains 10 questions asking to write Java programs that: 1. Create shape classes that derive from an abstract shape class and override methods to calculate area and volume. 2. Define a date class with constructors that throw exceptions for invalid dates, and display if a date is valid. 3. Create a menu-driven program to perform operations on integers like loading random numbers and saving to a file. 4. Accept a string, check if it's a file or directory, and perform operations to list text files or display a file's details. 5. Read item data from a file and allow searching by name, finding most expensive item, and displaying total cost.

Uploaded by

Omkar Bhate
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)
81 views2 pages

Java Slipq 21-22

This document contains 10 questions asking to write Java programs that: 1. Create shape classes that derive from an abstract shape class and override methods to calculate area and volume. 2. Define a date class with constructors that throw exceptions for invalid dates, and display if a date is valid. 3. Create a menu-driven program to perform operations on integers like loading random numbers and saving to a file. 4. Accept a string, check if it's a file or directory, and perform operations to list text files or display a file's details. 5. Read item data from a file and allow searching by name, finding most expensive item, and displaying total cost.

Uploaded by

Omkar Bhate
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/ 2

Q1) Create an abstract class shape. Derive three classes sphere, cone and cylinder from it.

Calculate
area and volume of all (use method overriding)

Q2) Define class MyDate with members day, month, year. Define default and parameterized
constructors. Accept values from the command line and create a date object. Throw user defined
exceptions – “InvalidDayException” or “InvalidMonthException” if the day and month are invalid. If
the date is valid, display message “Valid date”.

Q3) Write a menu driven program to perform the following operations on a set of integers as shown
in the following figure. A load operation should generate 10 random integers (2 digit) and display the
no on screen. The save operation should save the no to a file number.txt. The short menu provides
various operations and the result is displayed on the screen.

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

a. If it is a directory, list the name of text files. Also, display a count showing the number of files in
the directory. b. If it is a file display various details of that file.

Q5) Write a program to read item information( id, name, price, qty) from the file ‘item.dat’.
write a menu driven program to perform the following operations using random access file:

a. Search for a specific item by name

b. Find costliest item

c. Display all items and total cost.

Q6) Write a program to create a package “SY” which has a class SYMARKS (Computer Total,
MathsTotal, ElectronicsTotal). Create another package “TY” which has a class TYMarks (Theory,
Practical). Create another package “TY” which has a class TYMarks(Theory, Practical). Create
“n” objects of student class having roll number, name, SYMakrs and TYMarks. Add the marksof
SY and TY Computer subj ects and calculate 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.

Q7) Define a Student class (roll number, name, percentage). Define a default and parameterized
constructor. Keep a count 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.
Q8) Write a menu driven program to perform following operations. Accept operation accept the two
number using input dialog box. GCD will compute the GCD of two numbers and display in the
message box and power operation will calculate the value of an and display it in message box where
“a” and “n” are two inputted values.

Q9) Write a program to implement a simple arithmetic calculator. Perform appropriate validations.

Q10) Define a class saving account (acno, name, balance) .define appropriate and operation
withdraw(), deposit(), and viewbalance(). The minimum balance must be 500. Create an object and
perform operation. Raise user defined InsufficientFundException when balance is not sufficient for
withdraw operation.

You might also like