Page 80 - CA_Blue( J )_Class9
P. 80
4. What is the range of char data type?
Ans. Range of char data type:
‘\u0000’ (or 0) to ‘\uffff’ (or 65,535)
5. The following declaration is of some identifiers.
int a; float b; long c; char d;
Identify the datatype of the “dt”
dt = a*10 – b/c * (int)c;
Ans. float
6. Explain the term “type casting”.
Ans. Type casting is a process of changing the data type of one variable to another type. Two types of conversions are Implicit
and Explicit. It is also known as Type Conversion.
7. What are literals? Give any two examples.
Ans. Literals are values that are assigned to a variable, they can be of any data type and the assigned value is used as is
throughout the program. Two examples of Literals are:
1. real literal : 3.98
2. String literal : "India"
8. Distinguish between implicit and explicit data types conversion. Provide an example of each.
Ans.
Implicit data type conversion Explicit data type conversion
Occurs while assigning a value of smaller data type to a Occurs while assigning a value of larger data type to a
variable of larger data type. variable of smaller data type.
Conversion is automatically done by the compiler. It requires user’s intervention.
Example: Calculation of area of a circle. Example: Calculation of sum of 2 numbers
float r = 4.5f ; double a=0.0; int sum = 0; double a = 4.5, b=2.0;
a= 3.142 * r * r; sum = (int)(a+ b);
System.out.println(a); System.out.println(sum);
output : 55.42487496597301 output: 6
Here, the result is converted to “double” though “r” is a Here, though variables “a” and “b” are double and when
float variable automatically. it is tried to keep in int variable, user’s intervention is
required.
9. Distinguish between Static Initialisation and Dynamic Initialisation.
Ans.
Static Initialisation Dynamic Initialisation
Direct assignment of a constant to a variable. Initialising a variable during the execution of a program.
Example: Example:
float i1,i2,i3; public static void main( String args[] ) {
i1=i2 + i3; int r = 6; //Initialisation
double circumference;
circumference = 2 * Math.PI * r; //Dynamic Initialisation
System.out.println(" circumference= " + circumference);
}
10. Write down the data types of the following:
a. Fractional number
b. A small letter
c. A sentence
d. Long Integer
78 Touchpad Computer Applications-IX

