

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A mid-term assignment for an advanced computer programming course, covering various java programming topics such as class superclasses, interfaces, file handling, and linked lists. The assignment includes instructions for writing programs to print superclasses and implemented interfaces, reconstruct class source code, read files, calculate file sizes, copy files, manage student records using sequential access files and linked lists, and handle non-alphabetic characters. Bonus questions involve creating a subclass of properties to save and load in binary form.
Typology: Exercises
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Q-1) Write a program that takes the name of a Java class as a command-line argument and uses the Class class to print out all the superclasses of that class. (5) Q-2) Write a program that takes the name of a Java class as a command-line argument and uses the Class to prints out all interfaces implemented by a specified class or by any of its superclasses. Check for the case of classes that implement interfaces that extend other interfaces. For example, if a class implements java.awt.LayoutManager2, the LayoutManager2 interface and LayoutManager, its superinterface, should be listed.(10) Q-3) write a function void print(Class c) Given a class c, reconstructs the source code as completely as possible, like Fields, Methods, Getters and Setters, Private Fields and Methods and prints it on console.(10) Q-4) Write a program that prints out the first 10 lines of each file specified on the command line. User can specify as many files as he wants. (10) Q-5) Write a program that adds up and reports the size of all files in a specified directory. It should recursively scan any subdirectories, summing and reporting the size of the files that they contain, and incorporate those directory sizes into its final output. (10) Q-6 ) write a program to copy all files from one directory to another except for the ones that have size greater then 100 kb. (10) Q-7) Create a simple sequential-access file-processing program that might be used by teacher to help manage their student records. For each student, the program should obtain an ID number, the student’s first name, the student’s last name and the student’s grade. The data obtained for each student constitutes a record for the student and should be stored in an object of a class called Student. The program should save the records in a file specified by the user. (15) Q-8) Write program that read and display the grade information for each student stored in the above problem. The program should also display the class average. (15) Q-9) Create a simple linked list that might be used by teacher to help manage their student records. For each student, the program should obtain an ID number, the student’s first name, the student’s last name and the student’s grade. The data obtained for each student constitutes a record for the student and should be stored in an object of a class called Student. The program should save the records in the specified linked list. (20)
Q-10 Write a class that keeps a running total of all characters passed to it (one at a time) and throws an exception if it is passed a non-alphabetic character. (15) Bonus : The java.util.Properties class is essentially a hashtable that maps string keys to string values. It defines store( ) andload( ) methods that save and load its contents to and from a byte stream. These methods save the Properties object in a human-readable text format despite the fact that they use byte streams. Properties inherits the Serializable interface from its superclass,java.util.Hashtable. Define a subclass of Properties that implements storeBinary( ) and loadBinary( ) methods that use object serialization to save and load the contents of the Properties object in binary form. (20)