0% found this document useful (0 votes)
1 views11 pages

Java Practice Problems

The document outlines a series of programming exercises categorized by difficulty level (Easy, Medium, Hard) across various topics including conditional statements, loops, type casting, constructors, string functions, arrays, vectors, wrapper classes, method overriding, inheritance, packages, multithreading, and exception handling. Each topic presents a set of tasks designed to enhance programming skills in different areas. The exercises range from basic operations to more complex applications, such as banking systems and online payment gateways.

Uploaded by

koliharsha600
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)
1 views11 pages

Java Practice Problems

The document outlines a series of programming exercises categorized by difficulty level (Easy, Medium, Hard) across various topics including conditional statements, loops, type casting, constructors, string functions, arrays, vectors, wrapper classes, method overriding, inheritance, packages, multithreading, and exception handling. Each topic presents a set of tasks designed to enhance programming skills in different areas. The exercises range from basic operations to more complex applications, such as banking systems and online payment gateways.

Uploaded by

koliharsha600
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

3.

If Statements and Different Forms

Easy

1. Check whether a number is positive or negative.

2. Find the greater of two numbers.

3. Check whether a number is even or odd.

Medium

4. Find the largest among three numbers using nested if.

5. Check whether a year is a leap year.

6. Calculate electricity bill based on slabs.

Hard

7. Calculate grade based on marks with conditions for distinction, first class, pass and fail.

4. Switch Case & Conditional (?:) Operator

Easy

1. Calculator using switch.

2. Print weekday based on number (1–7).

3. Display month name from month number.

Medium

4. Menu-driven arithmetic operations.

5. Convert uppercase to lowercase using switch.

6. Find maximum of two numbers using conditional operator.

Hard

7. Mini ATM menu using switch (Balance, Deposit, Withdraw, Exit).

5. Looping Statement (for)

Easy

1. Print numbers from 1 to N.

2. Print multiplication table.

3. Find sum of first N natural numbers.

Medium
4. Find factorial of a number.

5. Check whether a number is prime.

6. Print Fibonacci series.

Hard

7. Print Pascal's Triangle.

6. Looping Statement (while & do-while)

Easy

1. Reverse a number.

2. Count digits in a number.

3. Find sum of digits.

Medium

4. Check palindrome number.

5. Check Armstrong number.

6. Generate multiplication tables until user exits.

Hard

7. Number guessing game using do-while.

7. Implicit Type Casting (Part I)

Easy

1. Assign int to double.

2. Assign char to int.

3. Assign float to double.

Medium

4. Show arithmetic between int and float.

5. Display ASCII values using implicit conversion.

6. Demonstrate automatic promotion in expressions.

Hard

7. Create a program showing all implicit conversions among primitive types wherever allowed.
8. Implicit Type Casting (Part II)

Easy

1. Demonstrate byte to int conversion.

2. Demonstrate short to long conversion.

Medium

3. Mix byte, short and int in expressions.

4. Show precision after float to double assignment.

5. Display binary values before and after promotion.

Hard

6. Create a table showing valid implicit conversions.

7. Explain results with suitable examples.

9. Explicit Type Conversion

Easy

1. Convert double to int.

2. Convert float to byte.

Medium

3. Convert int to char.

4. Convert long to short.

5. Demonstrate loss of precision.

Hard

6. Menu-driven primitive type converter.

7. Compare implicit and explicit conversions using examples.

10. Constructors

Part A (Constructors)

Easy

1. Default constructor.

2. Parameterized constructor.

3. Constructor initializing employee details.


Medium

4. Student class using constructor.

5. Bank account initialization.

6. Rectangle area using constructor.

Hard

7. Library book management using constructors.

Part B (Multiple Constructors)

Easy

1. Constructor overloading for Student.

2. Constructor overloading for Circle.

Medium

3. Employee class with 3 constructors.

4. Mobile class with default specifications.

Hard

5. Hotel booking system using constructor chaining.

6. Product inventory using overloaded constructors.

7. University admission object creation using different constructors.

11. Functions of String Class (Part I)

Easy

1. Find length of string.

2. Convert to uppercase.

3. Convert to lowercase.

Medium

4. Compare two strings.

5. Check startsWith() and endsWith().

6. Find character at index.

Hard

7. Build a mini text analyzer.


12. Functions of String Class (Part II)

Easy

1. Replace characters.

2. Extract substring.

3. Trim spaces.

Medium

4. Split a sentence.

5. Reverse a string.

6. Count vowels.

Hard

7. Password validator using String methods.

13. Arrays

Easy

1. Find largest element.

2. Find smallest element.

3. Calculate average.

Medium

4. Search an element.

5. Sort an array.

6. Merge two arrays.

Hard

7. Remove duplicate elements.

14. Vectors

Easy

1. Store student names.

2. Add and remove elements.

3. Display vector elements.


Medium

4. Search an element.

5. Sort vector.

6. Update vector values.

Hard

7. Student management system using Vector.

15. Wrapper Class (Primitive → Object)

Easy

1. Convert int to Integer.

2. Convert double to Double.

3. Convert boolean to Boolean.

Medium

4. Store wrapper objects in ArrayList.

5. Compare primitive and wrapper objects.

6. Demonstrate autoboxing.

Hard

7. Student marks system using wrapper classes.

16. Wrapper Class (Object → Primitive)

Easy

1. Convert Integer to int.

2. Convert Double to double.

3. Convert Character to char.

Medium

4. Demonstrate unboxing.

5. Perform arithmetic after unboxing.

6. Compare wrapper objects after unboxing.

Hard

7. Banking application using wrapper classes.


17. Method Overriding

Easy

1. Animal → Dog sound().

2. Shape → Circle area().

3. Vehicle → Bike start().

Medium

4. Employee salary().

5. Bank interest().

6. Person display().

Hard

7. Online payment system (UPI, Card, Net Banking).

18. Single & Multilevel Inheritance

Easy

1. Person → Student.

2. Animal → Dog.

3. Vehicle → Car.

Medium

4. Person → Employee → Manager.

5. Shape → Rectangle → Square.

6. Account → SavingsAccount.

Hard

7. University management using multilevel inheritance.

19. Multiple Inheritance (using Interfaces)

Easy

1. Printable and Showable.

2. Camera and MusicPlayer.

Medium
3. Sports interface.

4. Vehicle interface.

5. Smart Device interfaces.

Hard

6. Smart Home automation.

7. Online payment gateway using multiple interfaces.

20. Packages

Easy

1. Create a package with Calculator class.

2. Import MathOperations package.

3. Create package for Student.

Medium

4. Banking package.

5. Geometry package.

6. Employee package.

Hard

7. College Management System using multiple packages.

21. Multithreading (Part I)

Easy

1. Create a thread using Thread class.

2. Print numbers using two threads.

3. Display current thread name.

Medium

4. Print even and odd numbers using separate threads.

5. Countdown timer.

6. Digital clock simulation.

Hard

7. Railway reservation simulation.


22. Multithreading (Part II)

Easy

1. Create thread using Runnable.

2. Thread priority example.

3. Demonstrate sleep().

Medium

4. Join threads.

5. Producer simulation.

6. Parallel multiplication tables.

Hard

7. Multi-threaded file downloader simulation.

23. Try-Catch Block

Easy

1. Handle divide-by-zero.

2. Handle ArrayIndexOutOfBoundsException.

3. Handle NumberFormatException.

Medium

4. Multiple catch blocks.

5. Nested try-catch.

6. Input validation.

Hard

7. ATM transaction with exception handling.

24. Try-Catch-Finally

Easy

1. Demonstrate finally.

2. File opening simulation.

3. Database connection simulation.


Medium

4. Calculator with finally.

5. Login validation.

6. Resource cleanup example.

Hard

7. Banking transaction with finally.

25. Try-Catch-Finally (Advanced)

Easy

1. Invalid age exception handling.

2. File not found handling.

3. Input mismatch handling.

Medium

4. Multiple exceptions.

5. Nested finally.

6. Student marks validation.

Hard

7. Online shopping checkout with exception handling.

26. throw & throws (Part I)

Easy

1. Throw exception for negative age.

2. Throw exception for invalid marks.

3. Throw exception for insufficient balance.

Medium

4. Use throws with division.

5. Custom validation.

6. Password validation.

Hard

7. Railway ticket booking using throw and throws.


27. throw & throws (Part II)

Easy

1. Voting eligibility checker.

2. Mobile recharge validation.

3. Temperature validator.

Medium

4. Online exam login.

5. Student admission validation.

6. Product stock validation.

Hard

7. Airline reservation system with custom exceptions.

You might also like