If you are looking for the Java Programs for Freshers Practise PDF then you are in the right place. At the end of this post, we added a button to download the Java Interview Programs with Output/Solutions PDF for free.
Java Programs
In this post, we have shared the Java Programs with Output. This will be helpful for the students for their exams. The students can obtain questions for practice and help them to revise the questions and answers for each topic before exams.

This post will help beginners to understand various Java Programming Examples along with the Outputs. Â The post will contain various programs like simple hello world program, adding two numbers, printing pyramid in Java, etc., which can be helpful for freshers to understand the syntax and logic of Java programming.
Java Hello World Programs
- The Class keyword is used to declare a class in Java
- The Public keyword is an access modifier that represents visibility, which means this function is visible to all.
- Static is a keyword, used to make a static method. The advantage of the static method is that there is no need to create an object to invoke the static method. The main()
- The Method here is called by JVM, without creating any object for the class.
- Void is the return type of the method, it means this method will not return anything.
- Main: The main() method is the most important method in a Java program. It represents the startup of the program.
- String[] args is used for command line arguments.
- System.out.println()Â is used to print statements on the console
Leap Year Program in Java
import java.util.Scanner;
public class Lear_year {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
System.out.print("Enter any year:");
int year = s.nextInt();
boolean flag = false;
if (year % 400 == 0) {
flag = true;
} else if (year % 100 == 0) {
flag = false;
} else if (year % 4 == 0) {
flag = true;
} else {
flag = false;
}
if (flag) {
System.out.println("Year " + year + " is a Leap Year");
} else {
System.out.println("Year " + year + " is not a Leap Year");
}
}
}
Output :
Enter any year:2015
Year 2015 is not a Leap Year
Enter any year:2016
Year 2016 is a Leap Year