Here’s a comprehensive list of Core Java practical practice questions to help you strengthen your Java programming skills:
Basic Java Programs
Write a program to print "Hello, World!"
Write a program to add two numbers.
Write a program to swap two numbers (with & without a temporary variable).
Write a program to check if a number is even or odd.
Write a program to find the largest of three numbers.
Write a program to check if a number is prime.
Write a program to print Fibonacci series up to
nterms.Write a program to find the factorial of a number.
Write a program to reverse a number.
Write a program to check if a number is a palindrome.
String Manipulation
Write a program to reverse a string.
Write a program to check if a string is a palindrome.
Write a program to count vowels and consonants in a string.
Write a program to remove all whitespaces from a string.
Write a program to count the occurrences of a character in a string.
Write a program to convert a string to uppercase/lowercase.
Write a program to find the length of a string without using
length().Write a program to concatenate two strings without using
+.Write a program to check if two strings are anagrams.
Write a program to find the first non-repeated character in a string.
Array & Matrix Problems
Write a program to find the largest & smallest element in an array.
Write a program to sort an array (ascending/descending).
Write a program to reverse an array.
Write a program to find the sum of all elements in an array.
Write a program to find the second-largest number in an array.
Write a program to merge two sorted arrays.
Write a program to remove duplicates from an array.
Write a program to perform matrix addition/multiplication.
Write a program to find the transpose of a matrix.
Write a program to check if a matrix is symmetric.
OOPs Concepts
Create a
Studentclass with attributes (name,rollNo,marks) and methods to display details.Implement inheritance (
Animal→Dog,Cat).Demonstrate method overloading (compile-time polymorphism).
Demonstrate method overriding (runtime polymorphism).
Create an abstract class
Shapewith abstract methodarea()(implement inCircle,Rectangle).Create an interface
Drawablewith methoddraw()(implement inPen,Pencil).Write a program to show encapsulation (private fields with getters/setters).
Implement a singleton class.
Create a
BankAccountclass withdeposit(),withdraw(), and exception handling for insufficient balance.Demonstrate the use of
finalkeyword (variable, method, class).
Exception Handling
Write a program to handle
ArithmeticException(division by zero).Write a program to handle
ArrayIndexOutOfBoundsException.Write a program to handle
NullPointerException.Create a custom exception
InvalidAgeException(throw if age < 18).Demonstrate
try-catch-finallywith a file read operation.
Collections Framework
Write a program to sort an
ArrayListof strings.Write a program to remove duplicates from an
ArrayList.Write a program to iterate over a
HashMapand print key-value pairs.Write a program to check if a
LinkedListis empty.Write a program to reverse a
LinkedList.Write a program to find the frequency of words in a string using
HashMap.Write a program to sort a
HashSet.Write a program to compare two
ArrayLists for equality.Write a program to convert an array to
ArrayListand vice versa.Implement a
PriorityQueuefor custom objects (e.g.,Employeeby salary).
File Handling
Write a program to read a file and count the number of lines.
Write a program to write data to a file.
Write a program to copy contents from one file to another.
Write a program to count the occurrences of a word in a file.
Write a program to append text to an existing file.
Multithreading
Write a program to create a thread by extending
Threadclass.Write a program to create a thread by implementing
Runnable.Write a program to demonstrate thread synchronization.
Write a program to simulate a deadlock scenario.
Write a program to print even and odd numbers using two threads.
Miscellaneous
Write a program to print current date and time.
Write a program to convert
StringtoDate.Write a program to generate random numbers.
Write a program to compute the sum of digits until a single digit is obtained.
Write a program to implement a basic calculator (
+,-,*,/).
Difficulty Level: Advanced
Implement a LRU (Least Recently Used) cache.
Write a program to serialize and deserialize an object.
Implement a producer-consumer problem using
wait()andnotify().Write a program to find all permutations of a string.
Implement a binary search algorithm.
These questions cover Core Java fundamentals, OOPs, Collections, Exception Handling, File I/O, and Multithreading.
Tip: Start with basics, then move to advanced topics.
No comments:
Post a Comment