[go: up one dir, main page]

0% found this document useful (0 votes)
2 views3 pages

Java Practice Questions Corrected

The document contains 50 Java practice questions categorized into easy, medium, and hard levels. It covers fundamental concepts such as classes, objects, inheritance, exception handling, and advanced topics like multithreading and design patterns. Each question is designed to test and enhance the reader's understanding of Java programming.

Uploaded by

ss3347580
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)
2 views3 pages

Java Practice Questions Corrected

The document contains 50 Java practice questions categorized into easy, medium, and hard levels. It covers fundamental concepts such as classes, objects, inheritance, exception handling, and advanced topics like multithreading and design patterns. Each question is designed to test and enhance the reader's understanding of Java programming.

Uploaded by

ss3347580
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/ 3

50 Java Practice Questions (Easy, Medium, Hard)

Easy Questions
1. Write a Java program to print 'Hello, World!'.

2. Write a Java program to add two integers.

3. What is the difference between int and Integer in Java?

4. Explain the concept of a class and an object in Java.

5. Write a Java program to find the largest of three numbers.

6. How do you take input from the user using Scanner class?

7. Write a Java program to check if a number is even or odd.

8. What is the purpose of the main method in Java?

9. Write a Java program to print numbers from 1 to 10 using a loop.

10. Explain the concept of method overloading with an example.

11. What is a constructor in Java? Give an example.

12. Write a Java program to reverse a string.

13. What are access modifiers in Java? List them.

14. What is the difference between = = and .equals() in Java?

15. Write a Java program to check if a number is prime.

16. What is the use of the 'final' keyword in Java?

17. Write a Java program to find the factorial of a number using recursion.

18. Explain the difference between while and do-while loops.

19. What are arrays in Java? How do you declare and initialize them?

20. Write a Java program to sort an array of integers in ascending order.

Medium Questions
21. What is inheritance in Java? Give an example.

22. Write a Java program using inheritance and method overriding.


23. What is the difference between abstract class and interface?

24. Write a Java program to implement a simple calculator using switch case.

25. What are static methods and static blocks in Java?

26. Write a Java program to find duplicate elements in an array.

27. What is exception handling in Java? Write a try-catch example.

28. Write a Java program to read a file and display its content.

29. What is a package in Java? How do you create and use one?

30. Explain the use of 'this' and 'super' keywords in Java.

31. Write a Java program to implement a simple banking system (deposit, withdraw, balance).

32. What is polymorphism in Java? Explain with an example.

33. How is memory management handled in Java?

34. Write a Java program to create and use an ArrayList.

35. What is the difference between String, StringBuilder, and StringBuffer?

36. What is multithreading in Java? How do you create a thread?

37. Write a Java program to implement a thread using Runnable interface.

38. Explain the lifecycle of an applet in Java.

39. What is the difference between HashMap and TreeMap?

40. Write a Java program to demonstrate usage of HashMap.

Hard Questions
41. Write a Java program to implement a stack using an array.

42. How does garbage collection work in Java?

43. Write a Java program to connect to a MySQL database and retrieve data.

44. Explain synchronization and thread safety in Java.

45. Write a Java program to implement a binary search algorithm.

46. What is reflection in Java? Give a use case.

47. Write a Java program to serialize and deserialize an object.


48. What are design patterns? Explain Singleton pattern with code.

49. Write a Java program to create a GUI calculator using Swing.

50. Explain how to handle concurrency issues in multithreaded programs.

You might also like