0% found this document useful (0 votes)
110 views

Oops Lab Internal

This document contains 8 questions asking to write Java programs to perform various tasks: 1) Solve quadratic equations and read/display integers from a file 2) Calculate Fibonacci sequences and sort names 3) Get file information and create a simple applet 4) Perform integer division and handle exceptions 5) Handle mouse events 6) Create a client-server application to calculate circle areas 7) Implement producer-consumer problem and allow drawing shapes 8) Create abstract shapes class and simulate a traffic light

Uploaded by

seethas_ur
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views

Oops Lab Internal

This document contains 8 questions asking to write Java programs to perform various tasks: 1) Solve quadratic equations and read/display integers from a file 2) Calculate Fibonacci sequences and sort names 3) Get file information and create a simple applet 4) Perform integer division and handle exceptions 5) Handle mouse events 6) Create a client-server application to calculate circle areas 7) Implement producer-consumer problem and allow drawing shapes 8) Create abstract shapes class and simulate a traffic light

Uploaded by

seethas_ur
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

1. a) Write a Java program that prints all real solutions to the quadratic equation ax2 + bx + c = 0.

Read in a, b, c
and use the quadratic formula. If the discriminant b2 -4ac is negative, display a message stating that there are no real
solutions.
b) Write a Java Program that reads a line of integers, and then displays each integer, and the sum of all the integers
(Use StringTokenizer class of java.util)

2.a) Write a Java program that uses recursive functions to print the nth value in the Fibonacci sequence.
b) Write a Java program for sorting a given list of names in ascending order.

3. a) Write a Java program that reads a file name from the user, then displays information about whether the file
exists, whether the file is readable, whether the file is writable, the type of file and the length of the file in bytes.
b) Develop an applet that displays a simple message.

4. Write a program that creates a user interface to perform integer divisions. The user enters two numbers in the
textfields, Num1 and Num2. The division of Num1 and Num2 is displayed in the Result field when the Divide button is
clicked. If Num1 or Num2 were not an integer, the program would throw a NumberFormatException. If Num2 were
Zero, the program would throw an ArithmeticException Display the exception in a message dialog box.

5. Write a Java program for handling mouse events.

6. Write a Java program that implements a simple client/server application. The client sends data to a server. The
server receives the data, uses it to produce a result, and then sends the result back to the client. The client displays
the result on the console. For ex: The data sent from the client is the radius of a circle, and the result produced by the
server is the area of the circle. (Use java.net)

7.a) Write a Java program that correctly implements producer consumer problem using the concept of inter thread
communication.
b) Write a Java program that allows the user to draw lines, rectangles and ovals.

8.a) Write a java program to create an abstract class named Shape that contains an empty method named
numberOfSides ( ).Provide three classes named Trapezoid, Triangle and Hexagon such that each one of the classes
extends the class Shape. Each one of the classes contains only the method numberOfSides ( ) that shows the
number of sides in the given geometrical figures.
b) Write a java program that simulates a traffic light. The program lets the user select one of three lights: red, yellow,
or green. When a radio button is selected, the light is turned on, and only one light can be on at a time No light is on
when the program starts.

You might also like