Master the final 4 high-yield exam questions: Publishing Company Class Hierarchy, Multi-Catch Exception Handling, AWT Registration Form GUI, and SQLite Database Table Creation.
For a publishing company that markets both books and audio DVDs create a class publication that stores the price (type float) of a publication. From this class derive two classes: book, which adds a page count (type int) and dvd, which adds a playing time in minutes (type float). Each of these three classes should have a getdata() function to get its data from the user at the keyboard, and a putdata() function to display its data. Write a main() program to test the book and dvd classes by creating instances of them, asking the user to fill in data with getdata(), and then displaying the data with putdata().
super.getdata(sc) and super.putdata() inside the subclass methods! This eliminates code duplication, ensuring that the base class field (`price`) is queried and displayed cleanly before subclass-specific attributes are handled.
Always follow standard Java naming conventions in exams:
Publication, Book, Dvd).getdata(), putdata(), pageCount, playingTime).
Write a Java program demonstrating multiple exception handling.
Requirements:
• Prompt the user to:
◦ Enter two integers.
◦ Enter an array index.
• Perform division and access an array element.
• Handle:
◦ ArithmeticException
◦ ArrayIndexOutOfBoundsException
◦ InputMismatchException
Write a Java AWT program to create a simple student registration form.
Requirements:
• Create a Frame.
• Add the following AWT components:
◦ Labels
◦ TextFields (Student ID, Name, Age)
◦ Choice (Gender)
◦ Button (Register)
• Display a confirmation message when the Register button is clicked.
Write a Java program that creates a table in a SQLite database.
Requirements:
• Connect to library.db.
• Create a table named Books with the following fields:
◦ BookID
◦ Title
◦ Author
◦ Price
• Display a message indicating whether the table was created successfully.