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

Programming With Java (CL 8)

The document provides an introduction to programming with Java for Class VIII, defining key concepts such as programs, programming, and programming languages. It distinguishes between high-level languages (POP and OOP) and outlines the principles of Object Oriented Programming. Additionally, it includes several Java programming examples demonstrating basic arithmetic operations and geometric calculations.

Uploaded by

saifkhanready
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 views4 pages

Programming With Java (CL 8)

The document provides an introduction to programming with Java for Class VIII, defining key concepts such as programs, programming, and programming languages. It distinguishes between high-level languages (POP and OOP) and outlines the principles of Object Oriented Programming. Additionally, it includes several Java programming examples demonstrating basic arithmetic operations and geometric calculations.

Uploaded by

saifkhanready
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

ST.

AUGUSTINE’S DAY SCHOOL


Programming with Java
CLASS –VIII

Program : One single instruction or a set of instructions to do a particular


task is called program.

Programming : The act of writing computer programs that takes inputs,


processes and provides the desired output is called programming.

Programming Language : We use a particular language to write programs.


This is called programming language.

Programming Language

High level language Low level language Machine language

POP OOP

High level language : A high level language is closer to human language.


It can be categorized into POP and OOP.

1
Procedure Oriented Programming (POP) : Procedure Oriented Programming
is focused on procedure /logic for which the program or software is being
written. Examples- C, Fortran, Pascal, Basic etc.
Object Oriented Programming (OOP) : Object Oriented Programming
simulates the real world in software. Everything in this real world is
considered as an object. All objects are classified under specific classes.
This OOP is focused on objects. Examples – Java, C++, Python, .Net etc.

Principles of Object Oriented Programming(OOP) :


Object Oriented Programming is based on the following principles.
i) Encapsulation ii) Abstaction iii) Inheritance iv) Polymorphism.

Class : A class can be called as a template or a blueprint having some


common characteristics and behavior.

Object : an object is an identifiable entity with some characteristics


and behavior.

Syntax of class declaration :


public class classname
{ public static void main(String args[ ])
{ data members;
Member functions;
} //end of main()
} //end of class

1. Wap to calculate and print the sum of 2 numbers. (assign values to


variables)
public class Sum
{public static void main(String args[ ])
{ int x=25,y=30,s=0; // declaration and assigning values to the variables
s=x+y;
[Link](“Sum of 2 numbers is=”+s);
}
}

2
2. Wap to calculate and print the product of 3 numbers. (assign values to
variables)

public class Product


{public static void main(String args[ ])
{ nt x=25,y=30z=12,pr=1; // declaration and assigning values to the
variables
pr=x*y*z;
[Link](“Product of 3 numbers is=”+pr);
}
}

3. Wap to calculate and print the difference of 2 numbers. (assign values to


variables)
public class Subtract
{public static void main(String args[ ])
{ int x=45,y=30,sub=0; // declaration and assigning values to the variables
sub=x-y;
[Link](“Difference of 2 numbers is=”+sub);
}
}
4. Wap to calculate and print the quotient of 2 numbers. (assign values to
variables)
public class Quotient
{public static void main(String args[ ])
{int x=25,y=5;
double dv=0;// declaration and assigning values to the variables
dv=x/y;
[Link](“quotient of 2 numbers is=”+dv);
}
}

5. Wap to calculate and print the area and perimeter of a square (assign
values to variables)
public class Arp
{public static void main(String args[ ])

3
{ int x=24,ar=0,pr=0; // declaration and assigning values to the variables
ar= x*x;
pr= 4*x;
[Link](“ area of a square is=”+ar);
[Link](“ Perimeter of a square is=”+pr);

}
}

6. Wap to calculate and print the area and perimeter of a rectangle (assign
values to variables).
public class Pr_ar
{public static void main(String args[ ])
{ int l=24, b=12,ar=0,pr=0; // declaration and assigning values to the
variables
ar= l*b;
pr= 2*(l+b);
[Link](“ Area of a rectangle is=”+ar);
[Link](“ Perimeter of a rectangle is=”+pr);
}
}
7. Wap to calculate and print the area and circumference of a circle(assign
values to variables).
public class Ar_cr
{public static void main(String args[ ])
{ int r=21;
double ar=0.0,cr=0.0 pi=23.14; // declaration and assigning values to the
variables
ar= pi*r*r;
cr= 2*pi*r;
[Link](“ area of a circle is=”+ar);
[Link](“ Circumference of a circle is=”+cr);

}
}
__________________________________________________________

You might also like