Skip to content

Java Q&A: Prep for everything, or maybe just for nothing at all!

License

Notifications You must be signed in to change notification settings

DinethDilhara/java-prep-for-nothing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

learning-java-way

A collection of Java questions and answers to prep for everything, or maybe just for nothing at all!

JavaPrepForNothing ๐Ÿš€

Welcome to the JavaPrepForNothing repository! ๐Ÿš€

This repository contains a collection of over 50 Java questions along with their answers. These questions cover various fundamental topics in Java programming, including:

  • Control statements ๐Ÿ› ๏ธ
  • Repetitive loops ๐Ÿ”
  • Random and math methods ๐ŸŽฒ
  • Methods ๐Ÿ“š
  • Recursive functions ๐Ÿ”ƒ
  • Arrays ๐Ÿ“Š
  • Input validation โœ…
  • String manipulation with the String class ๐Ÿ”ก

Each question is designed to enhance your thought process and teach you how to approach problems with suitable logic. Whether you're a beginner looking to learn Java or an experienced developer seeking to refresh your skills, this repository provides valuable practice and insight into Java programming concepts.

Feel free to explore, practice, and improve your Java skills with these questions! ๐Ÿ’ก

  1. Write a Java program to calculate the sum of the first 100 natural numbers. ๐Ÿงฎ

  2. Create a Java program to print the multiplication table of a given number. ๐Ÿ”„

  3. Write a Java program to find the square root of a given number. โˆš

  4. Implement a Java program to calculate the factorial of a number without using recursion. โž•

  5. Create a Java program to check whether a given year is a leap year or not. ๐Ÿ“…

  6. Write a Java program to find the GCD (Greatest Common Divisor) of two numbers. ๐Ÿค

  7. Implement a Java program to swap two numbers without using a temporary variable. โ†”๏ธ

  8. Create a Java program to check whether a given string is a palindrome or not (ignore case). ๐Ÿ”„

  9. Write a Java program to count the number of vowels and consonants in a given string. ๐Ÿ”ก

  10. Implement a Java program to find the largest and smallest elements in an array. ๐Ÿ“Š

  11. Create a Java program to reverse the elements of an array. ๐Ÿ”ƒ

  12. Write a Java program to calculate the factorial of a number using recursion. โž•

  13. Implement a Java program to check whether a given number is a prime number or not. ๐Ÿ”ข

  14. Create a Java program to find the sum of all even numbers between 1 and 100. โž•

  15. Write a Java program to generate a random number between 1 and 100. ๐ŸŽฒ

  16. Implement a Java program to check whether a given string is an anagram of another string. ๐Ÿ”„

  17. Create a Java program to find the length of a string without using the length() method. ๐Ÿ”ก

  18. Write a Java program to remove all white spaces from a given string. ๐Ÿšซ

  19. Implement a Java program to count the frequency of each character in a given string. ๐Ÿ”ก

  20. Create a Java program to find the average of an array of numbers. ๐Ÿ“Š

  21. Write a Java program to check whether a given number is a perfect number or not. โœ”๏ธ

  22. Implement a Java program to check whether a given string is a valid palindrome or not (considering case and punctuation). ๐Ÿ”„

  23. Create a Java program to find the Fibonacci series up to n terms. ๐Ÿ”ข

  24. Write a Java program to reverse a sentence word by word. ๐Ÿ”

  25. Implement a Java program to find the second largest element in an array. ๐Ÿ“Š

  26. Create a Java program to check whether a given number is an Armstrong number or not. ๐Ÿ’ช

  27. Write a Java program to check whether a given char is a lowercase or uppercase. ๐Ÿ”ก

  28. Implement a Java program to find the reverse of a number. ๐Ÿ”ข

  29. Create a Java program to find the sum of digits of a given number. โž•

  30. Print the first Armstrong number between 1-500. ๐Ÿ’ช

  31. Create a Java program to find the sum of natural numbers divisible by 3 or 5 up to n. โž•

  32. Implement a Java program to convert a decimal number to binary. ๐Ÿ”„

  33. Write a Java program to print the Pascal's triangle up to n rows. โ–ฒ

  34. Implement a Java program to find the longest word in a given sentence. ๐Ÿ“

  35. Implement a Java program to find the sum of digits of a number without using loops. โž•

  36. Implement a Java program to check whether a given string is a valid email address or not. โœ‰๏ธ

  37. Write a Java program to sort an array of strings in alphabetical order. ๐Ÿ”ค

  38. Write a Java program to remove duplicates from an array. ๐Ÿšซ

  39. Write a Java program to check if two arrays are equal or not. โš–๏ธ

  40. Find a given element's position in the array. ๐Ÿ”

  41. Write a Java program to simulate a dice roll. ๐ŸŽฒ

  42. Write a Java program to generate a random password of a specified length. ๐Ÿ”

  43. Validate Integer input between 1-20. โœ…

  44. Write a Java program to find the area and circumference of a circle given its radius. ๐Ÿ”„

  45. Write a Java program to convert temperature from Celsius to Fahrenheit using a method. ๐ŸŒก๏ธ

  46. Write a Java program to calculate a person's age in years, months, and days based on their birth date and the current date. ๐ŸŽ‚

  47. Write a Java program to calculate the power of a number using recursion. ๐Ÿ”ข

  48. Write a simple Java program for a random number game. ๐ŸŽฒ

  49. Given a password guessing game with only 4 attempts. ๐Ÿ”

  50. Write a Java program to perform matrix addition. ๐Ÿ“Š

About

Java Q&A: Prep for everything, or maybe just for nothing at all!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages