0% found this document useful (0 votes)
3 views10 pages

Java Programming Basics for Beginners

The document contains a series of Java programming examples, each demonstrating different programming concepts such as printing output, using logical operators, and performing arithmetic operations. Each program includes a brief description, the source code, and the expected output. The examples cover topics like area calculations, loops, and conditional statements.

Uploaded by

biwaho4340
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)
3 views10 pages

Java Programming Basics for Beginners

The document contains a series of Java programming examples, each demonstrating different programming concepts such as printing output, using logical operators, and performing arithmetic operations. Each program includes a brief description, the source code, and the expected output. The examples cover topics like area calculations, loops, and conditional statements.

Uploaded by

biwaho4340
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 PROGRAMMING

Program No : 1
/* PROGRAM IN JAVA TO PRINT 3 LINES. */
public class Prog1_2023
{
public static void main(String[] args)
{
[Link]("CLASS XI");
[Link]("INFORMATION TECHNOLOGY");
[Link]("CBSE");
}

OUTPUT
CLASS XI
INFORMATION TECHNOLOGY
CBSE
Program No : 2
/* TO USE LOGICAL OPERATORS ( && || ! ) */
public class Prog2_2023
{
public static void main(String[] args)
{
int x=8,y=4,z=3;
[Link]((x>y)&&(y<z));
[Link]((x>y)||(y<z));
[Link] (!(x==y));
}
}

OUTPUT
false
true
true
Program No : 3

/* DIFFERENCE BETWEEN =(ASSIGNMENT) AND ==(EQUAL


TO)OPEARTOR */

public class Prog3_2023


{
public static void main(String[] args)
{
int x=7,y=9;
[Link](x==y);
[Link](x!=y);
}

OUTPUT
false
true
Program No : 4

/* PROGRAM TO USE * AND / OPERATOR */


public class Prog4_2023
{
public static void main(String[] args)
{
int x=10,z=7;
int y=x*z;
int a=x%7;
[Link](y+ "," +a);
}
}

OUTPUT
70,3
Program No : 5

/* TO FIND AREA OF A SQUARE */


public class Prog5_2023
{
public static void main(String[] args)
{
int side=8;
[Link]("Area of a Square is : " +side * +side);
}
}

OUTPUT
Area of a Square is : 64
Program No : 6

/* TO PRINT ALPHABETS USING FOR LOOP */


public class Prog6_2023
{
public static void main(String[] args)
{
for(char ch='A';ch<='Z';ch++)
[Link](ch+",");
}
}

OUTPUT
A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,
Program No : 7
/* TO PRINT TABLE OF A GIVEN NUMBER */
public class Prog7_2023
{
public static void main(String[] args)
{
int num=9;
for(int i=1;i<=10;++i)
[Link](num+" * "+i+" = "+num*i);
}
}

OUTPUT
9*1=9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
9 * 10 = 90
Program No : 8

/* PROGRAM TO USE ARITHMETIC OPERATORS */


public class Prog8_2023
{
public static void main(String[] args)
{
[Link](3+4);
[Link](8-4);
[Link](6*7);
[Link](25/5);
[Link](25%5);
}
}

OUTPUT
7
4
42
5
0
Program No : 9

/* PROGRAM TO FIND AREA OF RECTANGLE*/


public class Prog9_2023
{
public static void main(String[] args)
{
int length=3, breadth=4;
[Link]("Area of Rectangle = "
+length*breadth);

}
}

OUTPUT
Area of Rectangle =12
Program No : 10

/* PROGRAM TO FIND WHETHER THE NO. ENTERED IS


POSITIVE NUMBER OR NEGATIVE NUMBER*/

public class Prog10_2023


{
public static void main(String[] args)
{
int num=-2;
if(num>=0)
[Link]("POSITIVE NUMBER");
else
[Link]("NEGATIVE NUMBER");
}
}

OUTPUT
NEGATIVE NUMBER

You might also like