This action might not be possible to undo. Are you sure you want to continue?
(A constituent college of Manipal University, Manipal)
Manipal Karnataka 576 104
DEPARTMENT OF MASTER OF COMPUTER APPLICATIONS
LABORATORY MANUAL Department Laboratory Semester & branch Name of the faculty No of contact hours/week : Master of Computer Applications : Java Programming Lab (MCA-533) : 3rd Semester, MCA : Anuradha Rao :3
Submitted by: Mrs. Anuradha Rao
(Signature of the faculty) Date: Approved by:
(Signature of HOD) Date:
INSTRUCTIONS TO STUDENTS 1. Students should be regular and come prepared for the lab practice. 2. In case a student misses a class, it is his/her responsibility to complete that missed experiment(s). 3. Students should bring and maintain an observation book exclusively for the lab. 4. Once the experiment(s) get executed, they should show the program and results to the instructors and copy the same in their observation book. 5. Prescribed textbook and class notes can be kept ready for reference if required. 6. They should implement the given experiment individually. 7. While conducting the experiments students should see that their programs would meet the following criteria: y y y y y y Programs should be interactive with appropriate prompt messages, error messages if any, and descriptive messages for outputs. Programs should perform input validation (Data type, range error, etc.) and give appropriate error messages and suggest corrective actions. Comments should be used to give the statement of the problem and every function should indicate the purpose of the function, inputs and outputs Statements within the program should be properly indented Use meaningful names for class, variables and methods. Make use of Constants and type definitions wherever needed.
8. Questions for the lab examination need not necessarily be limited to the questions in the manual, but could involve some variations and / or combinations of the questions. Lab Evaluation Scheme Continuous evaluation = 60marks ( Bi-weekly evaluation of 10 marks ( Observation Book=5 marks Execution=3 marks Viva=2 marks ) For 6 evaluations = 10*6 = 60 marks ) End Sem Exam = 40 marks Total 100 marks
CONTENTS SL NO. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. TITLE OF EXPERIMENT Introduction to Java programming, Environment, basic programs Recursive methods, 1-D Arrays, 2-D Arrays Class Declarations , Operations on Objects Inheritance, polymorphism Packages Exception handling Mutli-threading String Handling File handling Networking Networking JDBC References
Java & Network Lab (MCA ± 533)
Week:1 (input use command line) 1. Introduction to JAVA Programming Environment: ± 2. Some simple programs in JAVA- display, command line input to a program Optional: 1. To find the roots of a quadratic equation 2. To demonstrate type conversion & type casting 3. Sum of individual digits of a number entered through command line, check if zero is entered. 4. Write a JAVA Program to evaluate the following series. Calculate the values up to the desired accuracy and also display the number of iterations. Try to use different break and continue statements wherever applicable. (a) 1-1/2+1/3-1/4+1/5+««««. (b) Sin(x)=x - x3/3! + x5/5! - x7/7! +««« Week-2: 1. Write a JAVA program to evaluate nCr = n!/r!(n-r)!. Use a recursive user defined function to obtain the factorial of a number and hence use it to evaluate the above expression. Use µstatic¶ wherever required. 2. Write a JAVA program to accept 10 integers from the keyboard and also a search number then implement the Linear search. 3. Write a JAVA program to accept two matrices of order n X m and then perform the following: a. Addition b. Subtraction Use a user-defined function to accept a matrix and another function to display the matrix. Check for the validity of multiplication of matrices. Optional: 4. Write recursive method to find the power of an entered number through the command line.
Week-3: 1. Create a Student class, which contains name, roll number and marks in 6 subjects. Write an interactive java program to display the results of 5 students in a neat format. Include proper member methods/constructors in the class. 2. Write a java program to create a class called Complex and implement the following by overloading the method add () which returns the complex number. Check all the possible formats of using the method add(). Use possible constructors.
3. Consider an example of declaring the examination results. Design 3 classes i.e., Student, Exam, and Result. The Student class has data members such as roll number, name, branch, and year of joining. Create Exam class by inheriting Student class. The Exam class has data members representing the marks scored in 6 subjects. Derive Result class from Exam class, and it has its own data members such as total marks and result. Write an interactive Java program to model this relationship. Week-4: 1. Imagine a company that markets both hardware and software. Create two base classes that store the title of the item and its price. Create an interface that will be implemented by both these classes hardware and software, where hardware item holds the category of item and its original manufacture and software holds type of software and operating system under which it works. Calculate the total sales for hardware as well as software items recorded for last 3 months. 2. Use an interface that is implemented in two classes named book with Title, Author¶s Name, AccessNo and Type (Typeofoperation) as its members and another class named student with Name, Regno, Semester and nofbissue (number of books issued) as its members. Based on the Type (Typeofoperation), issuedate or returndate is considered. Calculate the fine 0.50 paise for each book, if it is not returned within 7 days. Include required methods to get the information, to compute the fine and display the details of a student or a book. Week-5: Packages in java 1. Create a package called P1 with class Account(assume proper data members and member functions). Import this package in the main class to demonstrate the use of package. 2. Create a package called Mat with class Matrix (Data members row, col and array, Member functions: readMat() and displayMat()). Import this package in the main class and use that for inheriting in AddMat class which has function for adding two matrices and returning the resultant matrix. 3. Create a package called Array with class Arr, that includes the functions for creating any type of array and basics function with array like input & output array. Sorting any type of array. Import this in the main class and use it for manipulating and sorting any type of array. Week-6: Exception handling in Java (try to use try, catch, throw, throws and finally clauses wherever applicable) 1. Program for handling Arithmetic Exception, ArrayIndexOutOfBounds Exception. 2. Create a class called Account with member data acc_no, name and balance. Implements the member functions for input, output, deposit, withdraw and transfer. Implement following constraints using exception. (1) Minimum balance should be 500 (b) Minimum transfer amount should be 1000 (3) Valid data entry for account no. 3. In Matrix programming, while adding/multiplying matrix, check the validity of the matrix and throw suitable user defined exception.
Optional: 4. Define and use an exception class called ³NoMatchException´ that is thrown when a string is not equal to ³Good´. Week-7: Multithreading 1. Programs related to creating threads to do different tasks in two ways 2. Programs based on using synchronized keyword, wait(), notify(), join() Optional: 3. To implement Producer & Consumer Problem. Week-8: String Handling 1. Write a program to replace an entered word with ³Hello´ 2. Demonstrate equals() and == with a program. 3. Count and all the repeated appearance of an entered word. Replace each one with a new word interactively. 4. Use a String, reverse it and concatenate both and store them in a new String. Find the length, reverse each character of the resultant string. Optional: 5. Convert the starting word¶s char of a sentence to its uppercase. 6. Take a String, replace the first char from the left with the last char from right, till it left coincides with right. 7. Take a string as a sentence, check for a word starting with µMit¶ and replace it with some other word that is entered through the keyboard.
Week-9: File Handling 1. To demonstrate the methods available in the µFile¶ class. 2. Create a file containing 5 strings. Read the information from the file and sort and display them in ascending order. 3. Create a program to store the information of patients using object-serialization. Read the same using object-deserialization. Find how many patients visits a particular OPD, how many number of patients suffer from a particular disease. Display the information in a proper format. Optional: 4. Create a random access file that has RegNo, Name, Course and Age as information to be stored. Search for a RegNo entered by the user, display the information if exists else display µnot found¶. Add GPA to the end of the file
Week-10: Networking 1. Write a Java code for a client and server program. Use two instances of MS-DOS prompt. Run a client program on one prompt and the server program on the other. Note that the client-server programs should run on the same machine. Run the server program before running the client program. This program displays the messages from the client on server window. To stop the programs, type "Stop" at the client window. This should terminate the server program also. 2. Write a Java program to implement a FileServer. The client program will send the name of the text file to the server. The server program should display the content of the text file and also should display the number of alphabets, number of lines, number of spaces, number of digits & number of other characters present in the text file. Run both the programs on the same machine. Run the server program before running the client program. Optional: 3. Write Java programs to implement the following client-server model: The client program should send a string to the server. The server should determine whether the string is a palindrome or not and accordingly it should send a proper message to the client. Run both the programs on the same machine. Run the server program before running the client program. Week-11: Networking 1. Write a simple program to demonstrate the client-server model working in UDP sockets. 2. Write a Java program to implement a simple text oriented Chat Server. Assume that the client always initiates the chatting process and also the server supports only one client. Run both the programs on the same machine. Run the server program before running the client program. Week-12: JDBC 1. Create a Student database in Access and store the following information: name, roll number, branch, year of joining, and percentage marks. Write a menu driven Java program to do the following: (a) Insert a new record into the database. (b) Display all the records. (c) Delete a particular record. (d) Update a particular record. (e) Exit.
2. Create a Student database in Access and store the following information: name, roll number, branch, year of joining, and percentage marks. Write Java programs to implement the following client-server model: The client program should send the roll number to the server and the server program should display the corresponding student
record. Run both the programs on the same machine. Run the server program before running the client program. Optional: 3. Create an Item database in Access and store the following the following information: item name, item number, stock, and unit price. Write Java programs to implement the following client-server model: The client program should send the item number and quantity. The server program should validate the quantity and then it should display the bill for the corresponding item number. Run both the programs on the same machine. Run the server program before running the client program. References: 1. Patrick Naughton and Herbert Schildt, ³The Complete Reference ± Java 2´, 7th Edition,2nd Reprint, Tata McGrawHill,2007 2. Aaron Walsh and John Fronckowiak, ³ Java Programming Bible´, IDG Books India, 2000 Edition 3. E. Balguruswamy, ³Programming with Java ± A Primer 3/e´, 12th reprint, Tata McGrawHill, 2009
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.