Java Lab Programs

Please click the Required problem number to get the Code, numbering is as per our syllabus book, Screenshots of syllabus at the end of this post.

Click to see all at once

Outputs_Of_All_programs, (continue of 5), (continue of 5), (continue of 5),,,,,, program_9b (using extends Threads), (using implements Running), program_10b,,,, (program_14), (program_14)

  1. a) Write a program that displays welcome dear user followed by user name. Accept username from the user.
    b) Write a program to print the multiplication table (till 20) of a given number.
    c) Write a program that prompts the user for an integer and
    then prints out all the prime numbers up to that Integer.
  2. a) Write a program to create a class Rectangle. The class has attributes length and width. It should have methods that calculate the perimeter and area of the rectangle. It should have read Attributes method to read length and width from user.
    b) The Fibonacci sequence is defined by the following rule:
    The first two values in the sequence are 1 and 1. Every subsequent value is the sum of the two values preceding it.Write a Java program that uses both recursive and non
    recursive functions to print the n th value in the Fibonacci sequence.
  3. a) Write a program to check the compatibility for multiplication, if compatible multiply two matrices and find its transpose.
    b) Write a program that checks whether a given string is a palindrome or not. Ex: MALAYALAM is a palindrome. Accept the string as command line argument.
    c) Write a program for sorting a given list of names in ascending order
  4. a) Create an inheritance hierarchy of Rodent, Mouse, Gerbil, Hamster etc. In the base class provide methods that are common to all Rodents and override these in the derived classes to perform different behaviors, depending on the specific type of Rodent. Create an array of Rodent, fill it with different specific types of Rodents and call your base class methods.
    b) Write a 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. (Use Runtimepolymorphism).
  5. Design a package to contain the class Student that contains data members such as name, roll number and another package contains the interface Sports which contains some sports information. Import these two packages in a package called Report which process both Student and Sport and give the report.
  6. a) Write a program to demonstrate wrapper classes, and to fix the precision.b) Write a program that calculates roots of a quadratic equation.
    c) Write a program that illustrates Vector class.
  7. a) Write a program that reads on file name from the user then displays information about whether the file exists, whether the file is readable/writable, the type of file and
    the length of the file in bytes and display the content of the using File Input Stream class.
    b) Write a program that copies contents from one file to another file.(Using character streams).
  8. a) Write a program to generate a set of random numbers between two numbers x1 and x2, and x1>0.
    b) Write a 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)
    c) Using the Java API write a program to obtain the following output:
    Today’s date is <> The month is The year is days have passed in this year so far.
  9. a) Write a program that reads two numbers from the user to perform integer division into Num1 and Num2 variables. The division of Num1 and Num2 is displayed if they are integers. If Num1 or Num2 were not an integer, the program would throw a Number Format Exception. If Num2 were Zero, the program would throw an Arithmetic Exception.
    b) Create a user defined exception.
  10. a) Write a program that creates 3 threads by extending Thread class. First thread displays “Good Morning” every 1 sec, the second thread displays “Hello” every 2 seconds and the third displays Welcome” every 3 seconds. (Repeat the
    same by implementing Runnable).b) Write a program that correctly implements Producer- Consumer problem using the concept of Inter Thread Communication.
  11. a) Develop an applet that displays a simple message.
    b) Develop an applet that receives an integer in one text field, and computes its factorial Value and returns it in another text field, when the button named “Compute” is clicked.
  12. a) Write a program that allows user to draw lines, rectangles and ovals.
    b) Write a program that illustrates different AWT controls.
  13. a) Write a program for handling mouse events with adapter classes.
    b) Write a 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.
    c) Write a 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
  14. Write a 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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s