☕
B.TECH II YEAR • I SEMESTER • R25

Object Oriented Programming Through Java - Lab Manual

Java Lab Manual • Programming Practice Programs

LAB MANUAL

Object Oriented Programming Through Java Lab Programs

This tutorial provides Java Lab Programs on various topics of Object Oriented Programming Through Java. It includes Java basics, GUI programming, exception handling, multithreading, linked lists, abstract classes, file handling, event handling, hash tables, inter-thread communication and directory operations.

01

Use Eclipse or NetBeans platform and acquaint yourself with the various menus. Create a test project, add a test class, and run it. Explore auto suggestions, auto fill, code formatter and code refactoring such as renaming variables, methods and classes. Also try step-by-step debugging with a small program of about 10 to 15 lines containing at least one if-else condition and a for loop.

View Solution →
02

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. Handle possible exceptions such as division by zero.

View Solution →
04

Develop an applet in Java that receives an integer in one text field, computes its factorial and returns the value in another text field when the button named "Compute" is clicked.

View Solution →
05

Write a Java program that creates a user interface to perform integer divisions. The user enters two numbers in text fields Num1 and Num2. The division result is displayed when the Divide button is clicked. Handle NumberFormatException when the input is not an integer and ArithmeticException when Num2 is zero. Display the exception in a message dialog box.

View Solution →
06

Write a Java program that implements a multi-thread application with three threads. The first thread generates a random integer every 1 second. If the value is even, the second thread computes and prints the square of the number. If the value is odd, the third thread computes and prints the cube of the number.

View Solution →
07

Write a Java program to create a doubly linked list of elements, delete a given element from the list and display the contents of the list after deletion.

View Solution →
08

Write a Java program that simulates a traffic light. Allow the user to select red, yellow or green using radio buttons. On selecting a button, display an appropriate message such as "Stop", "Ready" or "Go" above the buttons in the selected color. Initially, no message should be shown.

View Solution →
09

Write a Java program to create an abstract class named Shape containing two integers and an empty method named printArea(). Provide Rectangle, Triangle and Circle classes that extend Shape. Each class should implement printArea() to print the area of the respective shape.

View Solution →
10

Suppose that a table named Table.txt is stored in a text file. The first line contains the header and the remaining lines correspond to rows in the table. The elements are separated by commas.

View Solution →
11

Write a Java program to display the contents of Table.txt using Labels arranged in a Grid Layout.

View Solution →
12

Write a Java program that handles all mouse events and shows the event name at the center of the window when a mouse event is fired. Use Adapter classes.

View Solution →
13

Write a Java program that loads names and phone numbers from a text file where each record is on one line and fields are separated by a tab (\t). Take a name or phone number as input and print the corresponding other value from the hash table. Use hash tables.

View Solution →
14

Write a Java program that correctly implements the producer-consumer problem using the concept of inter-thread communication.

View Solution →
15

Write a Java program to list all the files in a directory including the files present in all its subdirectories.

View Solution →