Page 110 - computer science (868) class 11
P. 110
// data members
// member methods
}
}
Here, two objects are created having the properties and functions of the sum class.
Array
Arrays can be defined as the sets of variables containing values of the same data types, having the same variable name
but different subscripts required to separate the values. So, when we declare an array, we are creating a sequence of
variables together. Syntax to declare an array is as follows:
Primitive_Datatype variable_name[]= new Primitive_Datatype[value];
For example,
int ar[]= new int[10]; //it creates an integer array of 10 elements
Interface
An interface is an Abstract class contains a combination of methods and variables. But the methods declared in an
interface have signatures only. By default, the methods are abstract in an interface. For example,
interface fan
{
void show();
}
String
A string is a sequence of characters stored in a single variable. They are written within “ ” (double quotation marks).
Unlike C/C++, Java strings are not terminated with a null character. Syntax of declaring a string:
String <variable> = "sequence_of_characters";
5.4 ARITHMETIC EXPRESSION
The arithmetic expressions are the expressions that contain variables, constants and arithmetic operators. They are
used for calculations. For example,
int a = 5, b = 6;
double c;
c = (a+b)/2.0;
5.4.1 Types of Arithmetic Expressions
There are two types of artithmetic expressions. They are: Pure Arithmetic Expression and Mixed Arithmetic Expression.
• Pure Arithmetic Expression: When the variables and constants in an expression are of the same data type, then the
expression is known as Pure Arithmetic Expression. For example,
int a,b,c;
a = 100;
b = 200;
c = a+b;
In the above expression, all the variables are of integer type.
• Mixed Arithmetic Expression: When the variables and constants in an expression are of different data types, then
the expression is known as Mixed Arithmetic Expression. For example,
int a;
float b;
double c;
a = 100;
b = 200.20f;
c = a + b;
In the above expression, the variables are of different data types.
108108 Touchpad Computer Science-XI

