Java Practical Question BSC IT 5
Java Practical Question BSC IT 5
1. Write a simple Java program that prints "Hello, World!" to the console.
2. Write a Java program that takes two integers as input and performs the following
operations: addition, subtraction, multiplication, and division. Display the results
3. Write a program that declares variables of different data types (int, double, char,
String) and initializes them with appropriate values. Print each variable's value.
4. Define a class Rectangle with properties length and width. Include methods to
calculate the area and perimeter of the rectangle. Create an object of the class and
display the results.
5. Write a Java Program to swap two numbers with the help of a third variable.
7. Write a Java Program to enter the number from the user and check whether it is
palindrome or not.
8. Write a Java Program to print all the prime numbers between 1 to 20 with the help of
loops.
10. Write a Java Program to enter the number from the user and check whether the
number is Armstrong or not.
11. Write a Java Program to enter the number form user and Print Factorial of a number
with the use of loop .
20. Create a simple Java applet that displays "Welcome to Java Applet!" on the applet
window. Make sure to include the necessary methods for initializing and painting the
applet.
21. Write a Java Program to create an array of ten elements by taking input from the
user and print it.
22. Write a Java Program to find the maximum element in the array.
23. Write a Java Program to calculate the sum of all the elements in the array.
25. Write a Java Program to merge two arrays and print it.
26. Write a Java Program to find the second largest element in the array.
27. Write a Java program that takes a string input from the user and reverses it without
using reverse function.
29. Write a Java Program to count the total number of characters in a string.
30. Write a Java Program to use Basic String Operations using different predefined string
functions.
31. Write a Java Program to Compare Strings using equals, equalsIgnoreCase, and
compareTo.
35. Write a Java Program to check whether the String is Anagram or not.
37. Write a Java Program to print all the duplicate characters in a string.
38. Write a Java Program to create a simple GUI application using Java swing.
39. Write a Java Program to create a simple Servlet that responds to HTTP requests.
40. Write a Java program to establish a connection to a MySQL database using JDBC
and create , read, update and delete data from the database.