Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
96 views

Java Lab Programs

This document provides 30 Java programming problems to practice in a lab setting. The problems cover basic Java concepts like printing output, defining classes and methods, inheritance, interfaces, exceptions, threads, file I/O, applets, and database connectivity using JDBC. Students are instructed to write each program on a separate page, include identifying information, and submit both physical and digital copies to the provided email address.

Uploaded by

aa bb
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views

Java Lab Programs

This document provides 30 Java programming problems to practice in a lab setting. The problems cover basic Java concepts like printing output, defining classes and methods, inheritance, interfaces, exceptions, threads, file I/O, applets, and database connectivity using JDBC. Students are instructed to write each program on a separate page, include identifying information, and submit both physical and digital copies to the provided email address.

Uploaded by

aa bb
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

JAVA PROGRAMMING (LAB COPY)

1. Write a java program to print “Hello World”.


2. Write a java program to implement a class that will contain following methods – add(),
subtract(), multiply(), divide(), and display(). Take inputs from user.
3. Write a java program to calculate distance between two points. Take co-ordinates from user.
4. Write a java program to implement a class called employee. It will contain instance variables
namely id, name, and basic_salary and two methods namely input() and output(). Create another
class that will inherit employee class. Create three methods namely calculate() – to calculate net
salary (net salary = basic salary + 15% of basic salary) , calc_bonus() – to calculate bonus
(bonus = 10% of basic salary) and add() – to add net salary with bonus.
5. Write a java program to find the volume of a cube, rectangular box and cylinder using function
overloading.
6. Write a java program to print Fibonacci series
7. Write a java program to check if a number is a Prime number or not
8. Write a java program to find the area of a square, a rectangle and a circle using function
overloading.
9. Write a java program to print the following pattern
*
**
***
****
10. Write a java program to Print the following pattern
B
LL
UUU
EEEE
11. Write a java program check and print whether a number is a Pronic number or not. [A Pronic
number is a number which is the product of two consecutive integers.]
Examples:
12 = 3 * 4
20 = 4 * 5
42 = 6 * 7
12. Design a class to overload a function series() as follows:
a. void series (int x, int n) – To display the sum of the series given below:
i. x1 + x2 + x3 + ……………. xn terms
b. void series (int p) – To display the following series:
i. 0, 7, 26, 63 p terms.
c. void series () – To display the sum of the series given below:
i. 1/2 +1/3 + 1/4 +... +1/10
13. Write a program in Java to calculate the volume of a Cube. Use parameterized constructor to
initialize the dimensions of the cube.
14. Write a program to create interface Cube. In this interface we have two methods volume() and
area(). Implement this interface in another class named MyClass and compute the volume and
area of a Cube.
15. Create a user-defined package and create a class within it. This class will contain a method that
will compare two numbers. Import this package into a java program to find the largest between
two numbers.
16. Create two interfaces inf1 and inf2. Both will have the same method named show() which will
display a message. Create a class which will implement both the interfaces and then call show()
to display their messages.
17. Write a program to create a file and write data into it using the methods OutputStream class.
18. Write a program to get the input from the user and store it into file. Using Reader and Writer
file.
19. Write a program to illustrate creation of threads using runnable class.(start method start each of
the newly created thread. Inside the run method there is sleep() for suspend the thread for 500
milliseconds).
20. Write a program to create two threads. In this class we have one constructor used to start the
thread and run it. Check whether these two threads are run are not.
21. Create a multithreaded program by creating a subclass of Thread and then creating, initializing,
and staring two Thread objects from your class. The threads will execute concurrently, and
display “Java is the best programming language” to the console window.
22. Write a program to get the reference to the current thread by calling currentThread() method.
Print the priority of the thread and then assign a new priority to it.
23. Write a program to illustrate usage of try/catch with finally clause.
24. Write a program containing multiple (at least three) catch statements occurring in a program.
25. Write a program for creation of user defined exception. Provide proper exception handling in the
program.
26. Write an Applet program to display the “Hello World” in the browser.
27. Write an Applet program that automatically display the text with Font Style, Font type using
getParameter() method.
28. Write an Applet program that has menu bar and a quit option and if the user clicks the quite
option the applet should quit.
29. Write an Applet program and draw a line, a rectangle, a circle, and an ellipse. Fill the shapes
with colours of your choice. Also, change the foreground and background colours.
30. Write a database connectivity program using JDBC API that creates and modifies a MySQL
database (You can use other DBMS too).

1. Each program should be written on A4 pages


2. Write name of the program, source code, and output
3. Add a cover page
4. Add an index page
5. Make a hard lab copy and a soft lab copy
6. Email the soft copy to debrajcst@wbscte.ac.in

You might also like