Page 152 - ComputerScience_Class_11
P. 152
2. class Calc {
public static void main(String[] args) {
int a = 5, b = 6;
String c;
c = (a + b) / 2.0;
System.out.println(c);
}
}
Ans. class Calc {
public static void main(String[] args) {
int a = 5, b = 6;
double c;
c = (a + b) / 2.0;
System.out.println(c);
}
}
3. class Conversion {
public static void main(String[] args) {
double d = 4.56;
int n = int d;
System.out.println("Result :" + n);
}
}
Ans. class Conversion {
public static void main(String[] args) {
double d = 4.56;
int n = (int) d;
System.out.println("Result :" + n);
}
}
Unsolved Questions
A. Tick ( ) the correct option.
1. What is the size of the char data type?
a. 2 bytes b. 8 bytes
c. 4 bytes d. 1 byte
2. How do you assign a String value?
a. string s="abc" b. String str="Abc";
c. String s=aa d. None of these
3. What will be the output of the following code?
double a=6.5, b=8.9;
int c= (int)(a+b);
System.out.println(c);
a. 12 b. 14
c. 15 d. 16
150 Touchpad Computer Science (Ver. 3.0)-XI

