0% found this document useful (0 votes)
17 views4 pages

Practice Set

The document lists 100 programming questions for Java developers, categorized into sections such as Basic Syntax and Variables, Loops and Control Flow, Arrays, Strings, Object-Oriented Programming, Exception Handling, Collections, Recursion, Input/Output, and Miscellaneous. Each question is designed to test various Java programming skills and concepts. The questions range from simple tasks like printing messages to more complex problems involving data structures and algorithms.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views4 pages

Practice Set

The document lists 100 programming questions for Java developers, categorized into sections such as Basic Syntax and Variables, Loops and Control Flow, Arrays, Strings, Object-Oriented Programming, Exception Handling, Collections, Recursion, Input/Output, and Miscellaneous. Each question is designed to test various Java programming skills and concepts. The questions range from simple tasks like printing messages to more complex problems involving data structures and algorithms.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Top 100 Questions for Java Developer

### Basic Syntax and Variables

1. Write a program to print "Welcome to Java" to the console.


2. Write a program to add two numbers entered by the user.
3. Write a program to swap two numbers using a temporary variable.
4. Write a program to check if a number is positive, negative, or zero.
5. Write a program to calculate the area of a circle given its radius.
6. Write a program to convert Celsius to Fahrenheit.
7. Write a program to find the remainder of two numbers without using % .
8. Write a program to check if a year is a leap year.
9. Write a program to calculate the average of three numbers.
10. Write a program to print the ASCII value of a character.

### Loops and Control Flow

11. Write a program to print numbers from 1 to 100.


12. Write a program to print all even numbers between 1 and 50.
13. Write a program to calculate the sum of the first n natural numbers.
14. Write a program to print the reverse of a number.
15. Write a program to find the factorial of a number using a loop.
16. Write a program to print a pattern of stars (e.g., a right triangle).
17. Write a program to check if a number is a palindrome.
18. Write a program to find the sum of odd numbers between 1 and 100.
19. Write a program to generate a multiplication table from 1 to 10.
20. Write a program to count the number of digits in a number.

### Arrays

21. Write a program to find the sum of all elements in an array.


22. Write a program to find the minimum element in an array.
23. Write a program to reverse an array without using a second array.
24. Write a program to sort an array in descending order.
25. Write a program to find duplicate elements in an array.
26. Write a program to rotate an array to the right by k steps.
27. Write a program to find the average of elements in an array.

https://codexjava.com/
28. Write a program to check if an array contains a specific element.
29. Write a program to merge two arrays into a single array.
30. Write a program to find the second smallest element in an array.

### Strings

31. Write a program to count the number of characters in a string.


32. Write a program to reverse a string using a loop.
33. Write a program to check if two strings are equal (case-sensitive).
34. Write a program to remove all spaces from a string.
35. Write a program to convert a string to lowercase without built-in methods.
36. Write a program to find the first non-repeating character in a string.
37. Write a program to check if a string is an anagram of another string.
38. Write a program to count the number of words in a sentence.
39. Write a program to replace all vowels in a string with ‘*’.
40. Write a program to concatenate two strings without using + .

### Object-Oriented Programming (OOP)

41. Write a program to create a Student class with name and age attributes.
42. Write a program to calculate the area of a rectangle using a class.
43. Write a program to demonstrate constructor overloading in a Box class.
44. Write a program to implement method overriding with a Dog class extending Animal .
45. Write a program to create an abstract Vehicle class with a Car subclass.
46. Write a program to implement an interface Shape with a Square class.
47. Write a program to demonstrate encapsulation with a BankAccount class.
48. Write a program to create a Person class with a static counter for objects created.
49. Write a program to simulate a TrafficLight class with color changes.
50. Write a program to create a Point class with methods to calculate distance.

### Exception Handling

51. Write a program to handle an ArrayIndexOutOfBoundsException .


52. Write a program to validate user input (e.g., age must be positive).
53. Write a program to catch and handle a NumberFormatException .
54. Write a program to throw a custom exception for invalid password length.
55. Write a program to use try , catch , and finally in a division operation.
56. Write a program to handle multiple exceptions (e.g., division by zero and null input).
57. Write a program to check if a file exists, handling FileNotFoundException .

https://codexjava.com/
58. Write a program to simulate a login system with exception handling.
59. Write a program to handle an exception when parsing a string to an integer.
60. Write a program to propagate an exception up the call stack.

### Collections

61. Write a program to add 10 integers to an ArrayList and print them.


62. Write a program to remove even numbers from an ArrayList .
63. Write a program to sort a LinkedList of strings.
64. Write a program to store key-value pairs in a HashMap and retrieve them.
65. Write a program to check if an element exists in a HashSet .
66. Write a program to find the intersection of two ArrayList s.
67. Write a program to reverse a LinkedList .
68. Write a program to count occurrences of elements using a HashMap .
69. Write a program to convert an ArrayList to an array.
70. Write a program to iterate over a HashMap using a loop.

### Recursion

71. Write a recursive program to calculate the sum of digits in a number.


72. Write a recursive program to reverse a string.
73. Write a recursive program to find the power of a number (e.g., x^n).
74. Write a recursive program to print the Fibonacci series up to n terms.
75. Write a recursive program to calculate the GCD of two numbers.

### Input/Output (I/O)

76. Write a program to read an integer from the user using Scanner .
77. Write a program to write a string to a file using FileWriter .
78. Write a program to read and display the contents of a file.
79. Write a program to count the number of characters in a file.
80. Write a program to append text to an existing file.
81. Write a program to copy contents from one file to another.
82. Write a program to read a CSV file and print its contents.
83. Write a program to check if a file exists and create it if it doesn’t.
84. Write a program to delete a file if it exists.
85. Write a program to read multiple lines from the console until "exit" is entered.

### Miscellaneous

https://codexjava.com/
86. Write a program to check if a number is an Armstrong number.
87. Write a program to generate the first n prime numbers.
88. Write a program to find the sum of elements in a 2D array.
89. Write a program to implement a simple calculator using methods.
90. Write a program to simulate a dice roll using Random .
91. Write a program to convert decimal to binary without built-in methods.
92. Write a program to find the largest element in a 2D array.
93. Write a program to check if a matrix is symmetric.
94. Write a program to implement a basic stack using an array.
95. Write a program to implement a queue using an array.
96. Write a program to find the LCM of two numbers.
97. Write a program to simulate a bank ATM with withdraw and deposit options.
98. Write a program to generate a random password of length 8.
99. Write a program to check if a string contains only digits.
100. Write a program to sort a list of names alphabetically.

https://codexjava.com/

You might also like