Page 28 - CA_Blue( J )_Class10
P. 28
Here, we can see that the behaviour of the Supercomputer has parallel processing, whereas the Desktop and Laptop
have serial processing. Similarly, Speed, Storage and Portability are different for different types of computers.
Example Speed:
class name : Square
Supercomputer : 415.53 PFLOPS
Characteristic:
Desktop : 1.5 GHz approx
side
Laptop : 1.5 GHz approx
Behaviours:
Let us take another real-time example: Area
Suppose, “Square” is a class. The characteristics are the side in cm and Behaviours are Perimeter
its area and perimeter.
Square Class
Object1 Object2
Characteristic: Characteristic:
side = 5 cm side = 2 cm
Behaviours: Behaviours:
area() : 25 cm 2 area() : 4 cm 2
perimeter() : 20 cm perimeter() : 8 cm
2.1 CLASS IN JAVA
A class in Java are non-primitive data types that act as a blueprint Definition
for creating objects of the same type. It may be viewed as a factory
that produces similar objects. A class may also be considered as a A class in Java is a template that can be used
new data type created by the user, that has its own functionality. to create objects and define object data types.
The class comprises characteristics and behaviour.
2.1.1 How to define a class in Java?
Suppose to define the below example:
class Square{
//Data Members
int side; // used for storing the side of the square
//Member Methods
void accept() // Accepts the side from the user
void area() // Calculates the area of the square
void perimeter() // Calculates the perimeter of the square
}
Here, “side” is the data member or attribute, and “accept ()”, “area ()” and “perimeter ()” are the member methods.
2626 Touchpad Computer Applications-X

