Lab II Tybsc
Lab II Tybsc
Lab II Tybsc
1. Write a Java program to create a class FileWatcher that can be given several filenames that
may or may not exist. The class should start a thread for each filename. Each thread will
periodically check for the existence of its file. If the file exists, then thread will display the
details of the file (viz. filename, permissions and size) on the console and then end. If file
does not exist then display appropriate error message. (35 marks)
2. Write PHP script to design a form to accept two strings (one smaller than the other) from the
user. Find whether the smaller string appears at the start of the larger string. Provide a
textbox to accept the string that will replace all occurrences of smaller string present in the
larger string. (35 marks)
1. Write a client-server program which displays the server machine’s date and time on the
client machine. (35 marks)
2. Write a PHP program to read a flat file student.dat that has student details as rno, name,
m1, m2, m3 as marks of 3 subjects. Display the data from the file in a tabular format.
Also display total and percentage of each student (35 marks)
1. Write a menu driven JDBC program to display the first record, last record, middle
record, nth record of a student. (Student table should contain student id, name and
class) (35 marks)
(Note : Examiners can replace Student table with Item, Book, Supplier, Customer,
Doctor, Patient or any other and provide the design of the table)
2. Write a PHP program to read a directory name and 2 letters. Display the file names in
that directory beginning with the either of the given 2 letters. Use regular
expressions if required. (35 marks)
1. Write program to create a window that has a textbox/label to show current time. The time
should be displayed in hh:mm:ss format. The thread should start displaying the time
when the user clicks the Start button and stop when the user clicks the Stop button.
(35
marks)
2. Write a PHP script for the following: Design a form to accept two numbers from the user.
Give options to choose an arithmetic operation (Use Radio Button). Display the result on
the next form. Use the concept of default parameters (35 marks)
1. Create the table stud in database with attributes as rno, name, m1, m2, m3 as marks
of 3 subjects. Accept student details from the console and add them in the table.
Continue the process until user enters a ‘0’ to the prompt “Add More [Yes(1)/No(0)]?
“ Also display the student details with total and percentage.
(35 marks)
2. Design a page to accept two numbers along with buttons GCD and LCM. Write the
function getgcd() and getlcm() that will return the gcd or lcm of given 2 numbers. Use
include construct to include the file of these functions and calculate the GCD and
LCM of the numbers given by user. (35 marks)
1. Create two singly linked lists for string data and perform following operations(35 marks)
a) Add element in list1
b) Add element in list2
c) Union
d) Display the reverse of the linked list after the union of lists
e) Intersection
f) exit
2. Write PHP program to define an interface shape which has two methods as area() and
volume(). Define a constant PI. Create classes cylinder and sphere which implements this
interface and calculate area and volume. Display the results. (35 marks)
1. Create a linked list containing the names of the days in a week. Display the menu that has
following options (35 marks)
a) Display the contents of the list using Iterator
b) Display the contents of the list in reverse order using ListIterator
c) Accept a day and display its index in the collection.
d) Exit
2. In PHP create login form with a username and password. Once the user logs in, the second
form should be displayed to accept user details as (name, city, phone_no). If the user does not
enter information within a specified time limit, then expire his session and give a warning
message (35 marks)
1. Design a servlet which counts how many times a user has visited a web page. If the user
is visiting the page for the first time then display a welcome message. If the user is
revisiting the page, then display the number of times page is visited. (Use Cookies) (35
marks)
2. Write a PHP program to read a directory name and extension. Display the files with
specified extension from that directory. (35 marks)
1. Create a JSP page to accept a number from the user and display it in words.
Ex. 125 – One Two Five (35 marks)
The output should be in blue color
2. Write a PHP script for the following: Design a form to accept a string. Write a function to
count the total number of vowels from the string. Show the occurrences of each vowel
from the string. Check whether the given string is palindrome or not without using built-
in functions (Use Radio buttons and the concept of function.) (35 marks)
2. Write a menu driven program to perform the following operations on an associative array.
a) Add defined value to the array
b) Remove specified element from the array
c) Display the elements of the array
d) Exit (35 marks)
1. Create a JSP page which accepts username in a text box and greets the user according to the
time on the server side. (35 marks)
For eg. User Name : tybsc
Good Morning tybsc (if it is Morning)
User Name : tybsc
Good Afternoon tybsc (if it is Afternoon)
User Name : tybsc
Good Evening tybsc (if it is Evening)
2. Derive a class square from a class rectangle. Also define a class circle. Create a interface
shape with a method findarea(). Implement this interface in all the classes. Include appropriate
data members and constructors in all classes. Write a PHP program to accept details of a
square, circle and rectangle and display the area
1. Write a Java thread program that displays the string “Welcome to Java” that moves
horizontally from left hand side of a frame/panel to the right hand side. (35 marks)
2. Write a PHP program to read a flat file transaction.date that has the details as tranctionid,
accno, amount, type, date. Type attribute can have the value as CR or DR that is debit or
credit. Display the transaction details in tabular format for the date given by the user. Also
display the total credit and total debit on that day. (35 marks)
1. Write a java program using threads for the following. (Use Swing or AWT)
TextArea TextArea
When the user clicks on the even button, your program should keep on displaying even
numbers till the user clicks on respective stop. Similarly, when the user clicks on the odd
button, your program should keep on displaying odd numbers till the user clicks on its
respective stop.(User may fix the range of even and odd numbers) (35 marks)
2. Write a PHP script to keep track of number of times a web page has been accessed. (35
marks)
1. Write a Java Program to create a Hash table to store book id and book name. Book id and
name should be accepted from the console. Write a menu driven program to add, search,
delete and display the contents of the hash table. Display the contents of the hash table in
tabular format. Display all the options till Exit is selected. (Do not use Swing).
(35 marks)
2. Write a PHP script to change the preferences of your web page like font style, font size, font
color, background color using cookie. Display selected settings on next web page and actual
implementation (with new settings) on third web page. (35 marks)
1. Write a Java program to accept ‘n’ student names from console and display the sorted list in
descending order (Use Comparator). (35 marks)
(Note: The examiners can change the data that is to be stored in the List i.e instead of student
names, accept ‘n’ book names or item names or city names etc.)
2. Write necessary class and member function definitions for a cricket player object. The
program should accept details from user (max :10) (player_code, name, runs, innings_played,
no_of_times_out). (35 marks)
1. Write a JDBC Program to accept a table name from console and display the following
details: Number of columns in the table, column names, datatype and the number of records.
(35
marks)
2. Write a PHP program to create an associative array of 10 elements. Accept each element
from the user and delete a specified element. Display the array before and after deletion.
Also, display proper error message if the element is not found in the array. (35 marks)
1. Write a Java program which sends the name of a text file from the client to server and
display the contents of that file on the client machine. If the file does not exists the
display proper error message to client. (35 marks)
2. Write a PHP script to define an interface shape which has two methods as area() and
volume(). Define a constant PI. Create classes cylinder and cube which implement this
interface and calculate area and volume . (35 marks)
1. Write a server program that echoes messages sent by the client. The process continues till the
client types “END”. (35 marks)
2. Design a page to accept two numbers along with buttons GCD and LCM. Write the PHP
function as getgcd() and getlcm() that will return the gcd or lcm of given 2 numbers. Use
include construct to include the file of these functions and calculate the GCD and LCM of the
numbers given by user. (35 marks)
1. Create a class student with attributes rno, name, age and class. Initialize values through
parameterize constructor. If age of student is not in between 15 to 21 then generate user
defined exception as “InvalidAgeException”. Similarly if name contains special symbols
or digits then raise exception as “InvalidNameException”. Handle these execeptions (35
marks)
Movie and Actor are related with many-to-many relationship with attribute rate in
number of Rs.
Create a RDB in 3 NF for the above and solve following
Create HTML Form having 2 Buttons and write PHP script to:
a) Print the name of the movies in which actor has acted. Accept actor name from user.
b) Update the release year of a movie. Accept movie name from user.
1. Write a program to accept a string as command line argument and check whether it is a
file or directory. If it is a directory then list the file names and their size in that directory.
Also, display a count of the number of files in the directory. Delete all the files in that
directory having the extension .txt (Confirm from user to delete a file or not). If it is a file
the display various details about that file. (35 marks)
(Note: Examiners can change the file extension from .txt to .dat or .tmp or .swp etc)
Write PHP script to print the bill in follwing format Accept the Bill number from user.
BillNo : BillDate :
Customer Name :
Gross Amount :
Total Discount :
Net Bill :
1. Write a program to read student information as rollno, name, class and percentage and
store it in a file stud.dat. Display the details of the student having a given rollno.
(35 marks)
2. Write a PHP script to read book.xml file and print specific content of the file using
DOMDocument Parser Book.xml file should contain following information with at least
five records with values (35 marks)
Book Info
Book No ,Book Name ,Author Name ,Price ,Year
(Note : Examiners can change the Book info file to student info, teacher info etc.)
1. Write a Java program to create GUI that displays all the font names available on a system
in a Combobox. Also display some text message. Apply the font selected from the combo
box to the text message. (35 marks)
2. Write Ajax program to read contact.dat file and print the contents of the file in tabular
form when the user clicks on the Print button (35 marks)
Contact.dat file contains srno, name, residence number, mobile number, context/relation
(Enter atleast 5 records in the Contact.dat file)
(Note : Examiners may change the contact.dat to emp.dat,dept.dat and provide proper
structure of the file)
1. Write a Java program to design a screen using swings that will create four text fields. First text
field for the text, second for what to find and third for replace. Display result in the fourth
text field. Also display the count of total no. of replacements made. On the click of ‘clear’
button, clear the contents in all the text boxes. (35 marks)
Enter Text
Text To Find
Text to Replace
No. Of occurrences
2. Write a script to create XML file “cricket.xml”. The element details of “circket.xml” are
as (35 marks)
<Circket>
<Player>
<Name>…………….</Name>
<Mathes>…………...</Matches>
<Innings>…………..</Innings>
<Notout>…………..</Notout>
<Runs>…………...</Runs>
</Player>
</Cricket>
1. Create an abstract class shape. Derive three classes sphere, cone and cylinder from it.
Calculate area and volume of all (use method overriding) (35 marks)
2. Draw a picture of Desktop computer and save this picture as “comp.jpeg”. Open this
picture as a watermark and resave it with the same filename. (35 marks)
(Note : Examinerc can change the picture with another shape)
1. Write a Java program to create GUI screen that display the following graphics (35 marks)
Fill outer and inner rectangle with red color. Fill outer circle with yellow color and inner circle
with blue color. Draw graphical shapes in black color.
(Note: The examiners can change the graphics that is to be drawn. However, atleast 4 graphical
objects need to be drawn and filled with different colors)
Write PHP script to print the doctors visiting to the Hospital in tabular format. Accept
hospital name from user.
1. Write a Java program to create the following GUI screen (35 marks)
Red: scrollbar1
Blue: Scrollbar2
Green: Scrollbar3
Label1 Label2
Apply
The first Scroll bar will handle red color; the second will handle green color and third will
handle the blue color. Set min = 0, max = 255 for the scroll bars. The screen has two labels
and one command button “Apply”. When user clicks on the Apply button, set the
background color of the label1 according to the RGB values set using the scrollbars. Display
the values of Red, Green, Blue in label2.
2. Write an Ajax program to print teacher information from the mysql table: Teacher
Teacher(no, name , suject, research area) (35 marks)
(Note : Examiner can change mysql table)
1. Write a Java program to create GUI screen that display the following graphics
(35 marks)
2. Write PHP script to validate email address according to user specification, send mail and
give proper error message if email address is not according to specification. (35 marks)
1. Create a JSP page which accepts username and password. User can have 3 login chances only.
If username and password is correct display a Welcome Message else display an error
message. (35 marks)
2. Write a PHP program to Create a class account (accno, cust_name). Derive two classes from
account as saving_acc (balance, min_amount) and current_acc(balance, min_amount).
Display a menu (35 marks)
a) Saving Account
b) Current Account
For each of this display a menu with the following options.
1. Create account
2. Deposit
3. Withdrawal
1. Write a program to create a package named Maths. Define classes as MathOp with static
methods to fine the maximum and minimum of three numbers. Create another package
Stats. Define a class StatsOp with methods to fine the average and median of three
numbers. Use these methods in main to perform operations on three integers accepted
using command line arguments. (35 marks)
1. Write a Java program to accept a decimal number in the text field. When the user clicks the
Calculate button the program should display the binary, octal, hexadecimal equivalents.
(35
marks)
Number Conversion
Decimal Number :
Binary Number :
Octal Number :
Hexadecimal Number :
CALCULATE
2. Write script to create XML file as “mymovies.xml”. The element details of this XML file
are as follows: (35 marks)
<Movie>
<MovieName>…………</MovieName>
<ActorName>………….</ActorName>
<ReleaseYear>………...</ReleaseYeear>
</Producer>……………</Producer>
</Movie>
(Note : Examiners can change xml file and give relevant data )