Java Programs With Output PDF Free Download

Download Java Programs for Freshers Practise PDF – Java Interview Programs with Output/Solutions PDF

Welcome to our new post. This post will provide you with a PDF of the Java Programs List. You can find the Java Programs with Output for Freshers, which you can also download in PDF format at the end of this post.

Checkout:

Java Programs

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-Programs

Java Hello World Program

  • class keyword is used to declare a class in java
  • public keyword is an access modifier which represents visibility, it means this function is visible to all.
  • static is a keyword, used to make a static method. The advantage of static method is that there is no need to create object to invoke the static method. The main()
  • method here is called by JVM, without creating any object for class.
  • void is the return type of the method, it means this method will not return anything.
  • Main: main() method is the most important method in a Java program. It represents 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

Download Java Programs with Output PDF

You can download the Java Programs with Output for Freshers PDF from the download button given below.


We hope you find this helpful content and are able to download the PDF for the list of Java Programs with Output.

Checkout:

Share This:

Leave a Comment