Day 1: Java Fundamentals & Core Syntax
1. Write a Java program to print your name using the \n (newline) and \t (tab) escape sequences.
2. Write a Java program to calculate the area and circumference of a circle given its radius (e.g.,
radius = 5.0).
3. Write a Java program to convert 25 degrees Celsius to Fahrenheit
4. Write a Java program to swap two integer without using a third variable.
5. Demonstrate implicit type explicit type.
6. Write a Java program that uses escape sequences to print the following output:
a. *****
* *
* *
*****
7. Declare an int variable, a char variable, and a boolean variable. Assign appropriate literals to
them and print their values.
8. Write a program to calculate the volume of a cube given its side length (e.g., side = 7).
9. Print the result of 10 / 3 using integer division and then using floating-point division.
10. Write a program to declare two String variables, concatenate them, and print the result.
Day 2: Operators & Control Flow
11. Write a Java program to implement a simple calculator using a switch statement. It should
take two numbers and an operator (+, -, *, /) as input, then perform the operation.
12. Check if a given number is even or odd using the modulus operator.
13. Find the largest of three numbers (e.g., 10, 25, 18) using if-else statements.
14. Assign a grade (A, B, C, D, F) based on marks using an else-if ladder. Prompt the user to enter
marks.
15. Determine whether a given number is divisible by 5 and 11.
16. Write a program to check if a person is eligible to vote (age 18 or above) using an if
statement.
17. Use the logical AND operator (&&) to check if a number is between 10 and 20 (inclusive).
18. Use the logical OR operator (||) to check if a character is a vowel (a, e, i, o, u).
19. Calculate the result of x++ and ++y for x=5 and y=5, printing the values of x, y, and the
results.
Day 3: Loops, Methods & Access Modifiers
20. Print the first 10 natural numbers using a for loop.
21. Print the first 10 natural numbers using a while loop.
22. Print the first 10 natural numbers using a do-while loop.
23. Display the multiplication table for a number using a for loop.
24. Create a method named
25. isPrime that takes an integer as input and returns true if it's a prime number, false otherwise.
26. Create overloaded methods for sum:
a. sum(int a, int b) returns the sum of two integers.
b. sum(int a, int b, int c) returns the sum of three integers.
27. Write a program to demonstrate nested methods in java
28. Print all even numbers between 1 and 100
29. Find the factorial of a given number using a
30. Write a method named calculatePower that takes a base and an exponent as input and
calculates the power
31. Write a program to demonstrate use of access modifiers public and private
32. Using a for loop, iterate from 1 to 10. Use continue to skip printing the number 5.
33. Using a for loop, iterate from 1 to 10. Use break to stop the loop when the number 7 is
encountered.
34. Create a method printGreeting(String name) that prints "Hello, " followed by the name.
35. Create a class Counter with a private integer variable count and a public method increment()
to increase count.
Day 4: Constructors, Overriding & Classes
36. Create a class Book with a default constructor that prints "Book object created" and a
parameterized constructor that takes title and author as arguments and prints them.
37. Create a class Student with attributes name and rollNo. Implement a parametrized
constructor to pass values.
38. Create a Shape class with a draw() method. Create a Circle class that extends Shape and
overrides the draw() method to print "Drawing a circle".
39. Create a base class Vehicle with a final method startEngine() that prints "Engine starting".
Create a subclass Car and try to override startEngine() (it should result in a compilation
error).
40. Create a Student class with constructor overloading:
a. One constructor takes name and rollNumber.
b. Another takes name, rollNumber, and age. Instantiate both and print their details.
41. Create a final class named SealedClass. Try to extend SealedClass with another class and
should result in compilation error.
42. Create a class Point with x and y coordinates and a constructor to initialize them.
43. Define a class Animal with a method makeSound(). Create subclasses Dog that override
makeSound() to print "Woof"
Day 5: Arrays & Recap
44. Declare an integer array, initialize it with 5 elements (e.g., 10, 20, 30, 40, 50), and print all
elements.
45. Read 5 integer elements from the user into an array and then print them.
46. Count the number of even and odd elements in an integer array.
47. Declare and initialize a String array with names of five fruits. Print each fruit name.
48. Calculate the product of all elements in an integer array.
Challenging Questions:
1. Write a Java program to print the following pattern:
a. J
b. JJ
c. JJJ
d. JJJJ
2. Create a class BankAccount with private attributes accountNumber and balance. Include
public methods deposit(double amount) and withdraw(double amount). Ensure withdraw
does not allow negative balance.
3. Write a program to print all prime numbers between 1 and 100. Use the isPrime method
created earlier.
4. Use static variable to count number of objects.
5. Write a Java program to display the ASCII value of the character 'A'.
6. Find the maximum of two numbers (e.g., num1 = 15, num2 = 8) using the ternary operator.
7. Create a static method named calculateSquare that takes an integer as input and returns its
square.
8. Demonstrate bitwise AND (&) and bitwise OR (|) operations with two integer numbers (e.g., a = 5,
b = 3).
9. Use a switch-case statement for a menu selection program:
a. Press 1 for "squareofanumber()"
b. Press 2 for "cubeofanumber()"
c. Press 3 for "Exit"
10. Write a program to check if a year is a leap year using if-else (A leap year is divisible by 4, but
not by 100 unless it's also divisible by 400).
11. Write a program that asks the user to enter numbers until they enter 0. Calculate and print
the sum of all entered numbers.
12. Write a program to demonstrate constructor chaining.
13. Print a right-angled triangle pattern using * with 5 rows using nested for loops.
14. Calculate the sum and average of all elements in an integer array (e.g., {1, 2, 3, 4, 5}).
15. Find the maximum and minimum values in an integer array (e.g., {7, 2, 9, 1, 5}).
16. Reverse the elements of an integer array (e.g., {1, 2, 3, 4, 5}
17. Copy all elements from one integer array to another new array.
18. Write a program to count the occurrences of a specific single element in an array.