Java Slipq 21-22
Java Slipq 21-22
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:
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.