Java Programming Practical
"L" Scheme - Sub Code: 25245
LAB EXERCISES
PART - A
10. Write a Java program for generating two threads, one for printing even numbers and other for printing odd numbers.
LAB EXERCISES
PART - A
- Write a program to print the individual digits of given 3-digit number.
- Write a program that asks the user to enter two integers, obtains the numbers from the user, and then prints the larger number followed by the words "is larger." If the numbers are equal, print the message “These numbers are equal.”
- Write a program to find the three digit Armstrong numbers.
- Write a program to read N numbers and find the largest and smallest numbers.
- Write a program in Java to create a String object. Initialize this object with your name. Find the length of your name using the appropriate String method. Find whether the character ‘a’ is in your name or not; if yes find the number of times ‘a’ appears in your name. Print locations of occurrences of ‘a’.
- Write a program to display total marks of 5 students using student class. Given the following attributes: Regno(int), Name(string), Marks in three subjects(Integer Array), Total (int).
- Write a program to show how a class implements two interfaces.
- Write a Java program to create your own exception subclass that throws exception if the sum of two integers is greater than 99.
- Write a program to create a text file using Byte stream classes
- Write a program to copy a file to another file.
PART – B
1. Write a program that accepts a shopping list of four items from the command line and stores them in a vector. Write a Menu based Program to perform the following operations using vector
1. Write a program that accepts a shopping list of four items from the command line and stores them in a vector. Write a Menu based Program to perform the following operations using vector
- To add an item at a specific location in the list.
- To delete an item in the list.
- To print the contents of the vector.
- To delete all elements
- To add an item at the end of the vector
2. a) Create a StringBuffer object and illustrate how to append characters. Display the capacity and length of the string buffer.
b) Create a StringBuffer object and illustrate how to insert characters at the beginning.
c) Create a StringBuffer object and illustrate the operations of the append() and reverse() methods.
c) Create a StringBuffer object and illustrate the operations of the append() and reverse() methods.
3. Write a program in Java with class Rectangle with the data fields width, length, area and colour. The length, width and area are of double type and colour is of string type. The methods are get_length(), get_width(), get_colour() and find_area(). Create two objects of Rectangle and compare their area and colour. If the area and colour both are the same for the objects then display “ Matching Rectangles”, otherwise display “ Non-matching Rectangle”.
4. Create a class to represent complex numbers. A complex number has the form real part + i * imaginary part. Provide constructor to enable an object of this class to be initialized when it is declared. Provide a no-argument constructor with default value in case no initializes are provided. Provide public methods for the following:
- Addition of two complex numbers
- Subtraction of two complex numbers
- Printing complex numbers in the form (a,b) where a is the real part and b is the imaginary part. (Pass objects as arguments)
5. Write a program to create a player class. Inherit the classes Cricket_player, Football_player and Hockey_player from player class.
6. Write a program to create a package for Book details giving Book Name, Author Name, Price, Year of Publishing.
7. A color can be created by specifying the red, green, blue values as integer parameters to the constructor of class Color. The values range from 0 to 255. Provide three horizontal scroll bars and ask the user to select the values of the colors by dragging the thumb in the scroll bar. Using the color selected, draw a rectangle.
8. Create an applet for simple calculator to perform Addition, Subtraction, Multiplication and Division using Button, label and Text field classes.
9. Draw a bar chart for the following details using Applets.Subject | Tamil | English | Maths | Physics |
Marks | 75 | 85 | 98 | 56 |
No comments :
Post a Comment