Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Java Lab

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

JNTUK, MVGRCE. II B.

tech CSE II Sem JAVA LAB Total no of weeks=14 WEEK 1: OOPS and COMMAND LINE ARGUMENTS
1. Write a java program to display a welcome message. 2. 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. 3. Write a java program that prompts the user for an integer and then prints out all prime numbers up to that integer. 4. 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 nth value in the Fibonacci sequence. 5. Write a java program to multiply two given matrices.

WEEK 2: METHOD OVERLOADING and STRING HANDLING


1. Write a java program to implement methods overloading. 2. Write a java program to implement constructor s overloading. 3. Write a java program that checks whether a given string is a PALINDROME or not. Ex: MADAM is a palindrome. 4. Write a java program to make frequency count of words in a given text. 5. Write a java program to use all the access specifiers (private, public, protected,...)

WEEK 3: INHERITANCE and POLYMORPHISM


1. Write a java program to implement SINGLE inheritance. 2. Create an inheritance hierarchy of rodent, mouse, gerbil, hamster, etc. In the base class provide methods that are common to all rodents and override this in the derived classes to perform different behaviours 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. 3. Write a java program to implement methods over-writing. 4. Write a java program to create an abstract class named Shape that contains an empty method named number of Sides (). 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, number Of Sides() that shows the number of sides in the given geometrical figure.

5. Write a java program that illustrates how run-time polymorphism is achieved. 6. Write a java program to implement INNER classes.

WEEK 4: PACKAGES and INTERFACES and UTIL PACKAGES.


1. Write a java program to implement MULTIPLE inheritance using interfaces. 2. Write a java program to demonstrate packages in JAVA. 3. Write a java program, using STRING TOKENIZER class, which reads a line of integers and then displays each integer and the sum of all integers. 4. Write a java program to use vectors, lists, etc.. (UTIL packages). 5. Write a java program to generate a set of random numbers between two numbers x1 and x2, and x1>0.

WEEK 5: IO PACKAGES
1. Write a java program to find the factorial of a given number (use BUFFERED reader class). 2. Write a java program to copy the contents of one file into another file. 3. Write a java 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 file using FILE INPUT STREAM class. 4. Write a java program that displays the number of characters, lines and words in a text/text file. 5. Write a java program to use data input and output stream classes.

WEEK 6: EXCEPTION HANDLING and MULTI-THREADING.


Write a java program to handle exception using tricatch block. Write a java program to handle multiple exceptions. Write a java program to handle user-defined exceptions. Write a java program that creates three threads. First displays Good Morning every one second, the second thread displays Hello every two seconds and the third thread diplays Welcome every three seconds. 5. Write a java program to create threads using runnable interface. 6. Write a java program that correctly implements producer consumer problem using the concept of inter thread communication. 1. 2. 3. 4.

WEEK 7: AWT and EVENT HANDLING (PART I)


1. Design a frame to calculate simple interst for given principle rate and time. 2. Design a frame which contains three buttons (red, blue, green) and change the background colour of the screen according to the button selected. 3. Write a java program to perform mouse events.

WEEK 8: AWT and EVENT HANDLING (PART II)


1. 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. 2. Write a java program which creates check-boxes, radio buttons, text fields, etc.. 3. Write a java program to design menu-bar and tool-bar.

WEEK 9: APPLETS and EVENT HANDLING.


1. Develop an applet that receives an integer in one text field, and computes it s factorial value and returns it in another text field, when the button named Compute is clicked. 2. Design paint brush applications (using applets). 3. Write a java program to implement adaptor classes.

WEEK 10: APPLETS


1. Write a java program that allows the user to draw lines, rectangles, and ovals. 2. Write a java program that simulates a traffic light. The program lets the user to select one of the 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 onwhen the program starts.

WEEK 11: SWING PACKAGES.


1. Design an online shopping application using swing packages. 2. Suppose that a table named table.txt is stored in a text file. The first line in the file is the header and the remaining lines correspond to the rows in the table. The elements are separated by commas. Write a java program to display the table using Jtable component.

WEEK 12: SWINGS


1. Write a java program that lets users create Pie charts. Design your own interface (with Swings and AWT). 2. Write a java program to implement different types of panels.

WEEK 13: STACKS and QUEUES


1. A) Write a java program that: i) Implements stack ADT ii) Converts infix expression to Postfix expression iii) Evaluates the postfix expression.

B) Write a java program to implement a queue using user defined exception handling(also make use of throw, throws).

WEEK 14: NETWORK PROGRAMMING


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 the circle and the result produced by the server is the area of the circle (use JAVA.net).

You might also like