0% found this document useful (0 votes)
8 views5 pages

Java Programs: Basics to Advanced

Uploaded by

monicabungla
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)
8 views5 pages

Java Programs: Basics to Advanced

Uploaded by

monicabungla
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

JAVA PROGRAM

PROGRAM 1 – Print Hello World


public class Hello {
public static void main(String[] args) {
[Link]("Hello World");
}
}
JAVA PROGRAM
PROGRAM 2 – Add Two Numbers
public class AddNumbers {
public static void main(String[] args) {
int a = 10, b = 20;
int sum = a + b;
[Link]("Sum = " + sum);
}
}
JAVA PROGRAM
PROGRAM 3 – Check Odd or Even
public class OddEven {
public static void main(String[] args) {
int num = 7;
if(num % 2 == 0)
[Link]("Even Number");
else
[Link]("Odd Number");
}
}
JAVA PROGRAM
PROGRAM 4 – Find Largest of Three Numbers
public class Largest {
public static void main(String[] args) {
int a = 15, b = 22, c = 9;
if(a > b && a > c)
[Link]("A is Largest");
else if(b > c)
[Link]("B is Largest");
else
[Link]("C is Largest");
}
}
JAVA PROGRAM
PROGRAM 5 – Print Multiplication Table
public class Table {
public static void main(String[] args) {
int num = 5;
for(int i = 1; i <= 10; i++) {
[Link](num + " x " + i + " = " + (num * i));
}
}
}

You might also like