TOP 100 CORE JAVA PRACTICE QUESTIONS
✅TOP 100 CORE JAVA PRACTICE QUESTIONS
Here are top 100 core java practical questions mostly asked in interview.
Conditional Statements
- Write a program to check if a number is positive, negative, or zero.
- Write a program to find the largest of three numbers.
- Write a program to check if a number is even or odd.
- Write a program to check if a character is a vowel or consonant.
- Write a program to check if a year is a leap year or not.
- Write a program to check if a number is prime.
- Write a program to find the greatest of three numbers using the ternary operator.
- Write a program to check if a number is a palindrome.
- Write a program to check if a string is a palindrome.
- Write a program to print the day of the week based on a number (1-7).
Patterns
- Write a program to print a pyramid pattern.
- Write a program to print a reverse pyramid pattern.
- Write a program to print a right-angled triangle pattern.
- Write a program to print an inverted right-angled triangle pattern.
- Write a program to print a diamond pattern.
- Write a program to print a hollow square pattern.
- Write a program to print a hollow triangle pattern.
- Write a program to print a Pascal's triangle.
- Write a program to print a Floyd's triangle.
- Write a program to print a butterfly pattern.
Series
- Write a program to print the Fibonacci series up to a given number.
- Write a program to print the factorial of a number.
- Write a program to print the sum of the first n natural numbers.
- Write a program to print the sum of the first n odd numbers.
- Write a program to print the sum of the first n even numbers.
- Write a program to print the prime numbers in a given range.
- Write a program to print the sum of digits of a number.
- Write a program to print the Armstrong numbers in a given range.
- Write a program to print the perfect numbers in a given range.
- Write a program to print the sum of the series 1 - 2 + 3 - 4 + ... + n.
Combination of Patterns/Series/OOP Concepts
- Write a program to print a pyramid pattern of prime numbers.
- Write a program to print a right-angled triangle pattern of Fibonacci numbers.
- Write a program to print the factorial of each number in a given range using recursion.
- Write a program to check if a given number is a palindrome using a method.
- Write a program to print a diamond pattern using the sum of digits of numbers.
- Write a program to print a pattern of Armstrong numbers.
- Write a program to print a combination of Pascal's triangle and prime numbers.
- Write a program to print the sum of the first n prime numbers using a method.
- Write a program to print the sum of the series 1 - 2 + 3 - 4 + ... + n using a method.
- Write a program to print the factorial of numbers in a pattern.
this
Keyword
- Write a program to demonstrate the use of the
this
keyword in constructors. - Write a program to demonstrate the use of the
this
keyword to refer to instance variables. - Write a program to demonstrate the use of the
this
keyword to invoke current class methods. - Write a program to demonstrate the use of the
this
keyword to return the current class instance. - Write a program to demonstrate the use of the
this
keyword in method chaining. - Write a program to demonstrate the use of the
this
keyword to invoke a constructor. - Write a program to demonstrate the use of the
this
keyword to pass an argument in the constructor call. - Write a program to demonstrate the use of the
this
keyword to resolve shadowing problem. - Write a program to demonstrate the use of the
this
keyword in setter methods. - Write a program to demonstrate the use of the
this
keyword to access class members.
super
Keyword
- Write a program to demonstrate the use of the
super
keyword to access superclass variables. - Write a program to demonstrate the use of the
super
keyword to invoke superclass methods. - Write a program to demonstrate the use of the
super
keyword to invoke superclass constructors. - Write a program to demonstrate the use of the
super
keyword to access superclass methods in a method overriding scenario. - Write a program to demonstrate the use of the
super
keyword in constructor chaining. - Write a program to demonstrate the use of the
super
keyword to call superclass static methods. - Write a program to demonstrate the use of the
super
keyword in an inheritance hierarchy with multiple levels. - Write a program to demonstrate the use of the
super
keyword to access superclass fields when they are shadowed by subclass fields. - Write a program to demonstrate the use of the
super
keyword in the context of a superclass reference. - Write a program to demonstrate the use of the
super
keyword in method overriding with return types.
final
Keyword
- Write a program to demonstrate the use of the
final
keyword with variables. - Write a program to demonstrate the use of the
final
keyword with methods. - Write a program to demonstrate the use of the
final
keyword with classes. - Write a program to demonstrate the use of the
final
keyword to create immutable objects. - Write a program to demonstrate the use of the
final
keyword in method parameters. - Write a program to demonstrate the use of the
final
keyword with static variables. - Write a program to demonstrate the use of the
final
keyword with instance variables. - Write a program to demonstrate the use of the
final
keyword in nested classes. - Write a program to demonstrate the use of the
final
keyword in anonymous classes. - Write a program to demonstrate the use of the
final
keyword with local variables in a method.
Methods
- Write a program to demonstrate method overloading.
- Write a program to demonstrate method overriding.
- Write a program to demonstrate the use of static methods.
- Write a program to demonstrate the use of instance methods.
- Write a program to demonstrate the use of recursive methods.
- Write a program to demonstrate the use of the
main
method. - Write a program to demonstrate the use of the
valueOf
method in theString
class. - Write a program to demonstrate the use of the
compareTo
method in theString
class. - Write a program to demonstrate the use of the
substring
method in theString
class. - Write a program to demonstrate the use of the
length
method in theString
class.
Miscellaneous
- Write a program to demonstrate the use of the
Math
class methods. - Write a program to demonstrate the use of the
Arrays
class methods. - Write a program to demonstrate the use of the
StringBuilder
class methods. - Write a program to demonstrate the use of the
StringBuffer
class methods. - Write a program to demonstrate the use of the
Scanner
class methods. - Write a program to demonstrate the use of the
Random
class methods. - Write a program to demonstrate the use of the
System
class methods. - Write a program to demonstrate the use of the
Locale
class methods. - Write a program to demonstrate the use of the
Date
class methods. - Write a program to demonstrate the use of the
Calendar
class methods.
Advanced
- Write a program to demonstrate the use of nested loops.
- Write a program to demonstrate the use of the
switch
statement. - Write a program to demonstrate the use of labeled
break
andcontinue
. - Write a program to demonstrate the use of exception handling using
try
,catch
,finally
. - Write a program to demonstrate the use of custom exceptions.
- Write a program to demonstrate the use of
assert
statement. - Write a program to demonstrate file reading and writing using
FileReader
andFileWriter
. - Write a program to demonstrate file reading and writing using
BufferedReader
andBufferedWriter
. - Write a program to demonstrate reading and writing binary data using
FileInputStream
andFileOutputStream
. - Write a program to demonstrate reading and writing objects using
ObjectInputStream
andObjectOutputStream
.
These questions cover a wide range of core Java concepts and provide practical exposure to various topics.