Professional Documents
Culture Documents
Notes For Class 11 Ev2 Syllabus Chapter
Notes For Class 11 Ev2 Syllabus Chapter
Notes For Class 11 Ev2 Syllabus Chapter
Write a program to input a string (word). Convert it into lowercase letters. Count
and print the frequency of each alphabet present in the string. The output should
be given as:
char ch;
System.out.println(“Output:”);
System.out.println(“==========================”);
System.out.println(“Alphabet\tFrequency”);
System.out.println(“==========================”);
/* Counting frequency of alphabets begins below */
int count=0;
count = 0;
if(ch==i) //first checking the whole string for ‘a’, then ‘b’ and
so on
System.out.println(i+”\t\t”+count);
}
}
}
==========================
Alphabet Frequency
==========================
a 2
e 1
h 2
i 1
o 2
r 1
u 1
w 1
y 1
import java.util.*;
class DisariumNumber
{
int n,rem, sum,len;
DisariumNumber()
{
n =0;
rem = 0;
sum = 0;
}
void read()
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter a number : ");
n = sc.nextInt();
}
void cal()
{
read();
int copy = n;
String s = Integer.toString(n); //converting the number into a String
len = s.length(); //finding the length of the number
while(copy>0)
{
rem = copy % 10; //extracting the last digit
sum = sum + (int)Math.pow(rem,len);
len--;
copy = copy / 10;
}
if(sum == n)
System.out.println(n+" is a Disarium Number.");
else
System.out.println(n+" is not a Disarium Number.");
}
public static void main(String[] args){
DisariumNumber ds= new DisariumNumber();
ds.cal();
}
}
Enter a number : 135
135 is a Disarium Number.
Enter a number : 234
234 is not a Disarium Number.
Enter a number : 89
89 is a Disarium Number.
Write program to find the whether the given number is evil number.
Write program to find whether the given number is Smith number
Program to check the prime number.
program to sort array using bubble sort
program to sort array using selection sort
program to search an element in array using linear search
program to search an element in array using binary search
Convert the following to their binary equivalents
(784)10
Answer
2 Quotient Remainder
2 784 0 (LSB)
2 392 0
2 196 0
2 98 0
2 49 1
2 24 0
2 12 0
2 6 0
2 3 1
2 1 1 (MSB)
Question 2
(999)10
Answer
2 Quotient Remainder
2 999 1 (LSB)
2 Quotient Remainder
2 499 1
2 249 1
2 124 0
2 62 0
2 31 1
2 15 1
2 7 1
2 3 1
2 1 1 (MSB)
Question 3
(1401)10
Answer
2 Quotient Remainder
2 1401 1 (LSB)
2 700 0
2 Quotient Remainder
2 350 0
2 175 1
2 87 1
2 43 1
2 21 1
2 10 0
2 5 1
2 2 0
2 1 1 (MSB)
Question 4
(1423)10
Answer
2 Quotient Remainder
2 1423 1 (LSB)
2 711 1
2 Quotient Remainder
2 355 1
2 177 1
2 88 0
2 44 0
2 22 0
2 11 1
2 5 1
2 2 0
2 1 1 (MSB)
Question 5
(478.75)10
Answer
2 Quotient Remainder
2 478 0
2 Quotient Remainder
2 239 1
2 119 1
2 59 1
2 29 1
2 14 0
2 7 1
2 3 1
2 1 1
0.75 x 2 = 0.5 1
0.5 x 2 = 0 1
Question 6
(165.35)10
Answer
Converting integral part
2 Quotient Remainder
2 165 1
2 82 0
2 41 1
2 20 0
2 10 0
2 5 1
2 2 0
2 1 1
0.35 x 2 = 0.7 0
0.7 x 2 = 0.4 1
0.4 x 2 = 0.8 0
0.8 x 2 = 0.6 1
Therefore, (165.35)10 = (10100101.0101)2
(277.27)10
Answer
2 Quotient Remainder
2 277 1
2 138 0
2 69 1
2 34 0
2 17 1
2 8 0
2 4 0
2 2 0
2 1 1
0.27 x 2 = 0.54 0
Multiply = Resultant Carry
0.54 x 2 = 0.08 1
0.08 x 2 = 0.16 0
0.16 x 2 = 0.32 0
Question 8
(322.2)10
Answer
2 Quotient Remainder
2 322 0
2 161 1
2 80 0
2 40 0
2 20 0
2 10 0
2 5 1
2 2 0
2 Quotient Remainder
2 1 1
0.2 x 2 = 0.4 0
0.4 x 2 = 0.8 0
0.8 x 2 = 0.6 1
0.6 x 2 = 0.2 1
Question 1
(1010110)2 to ( )10
Answer
Binary
Power Value Result
No
0 (LSB) 20 1 0x1=0
1 21 2 1x2=2
1 22 4 1x4=4
Binary
Power Value Result
No
0 23 8 0x8=0
1 24 16 1x16=16
0 25 32 0x32=0
1 (MSB) 26 64 1x64=64
Question 2
(1000011)2 to ( )10
Answer
Binary
Power Value Result
No
1 (LSB) 20 1 1x1=1
1 21 2 1x2=2
0 22 4 0x4=0
0 23 8 0x8=0
0 24 16 0x16=0
0 25 32 0x32=0
1 (MSB) 26 64 1x64=64
Equivalent decimal number = 1 + 2 + 64 = 67
Question 3
(1100111)2 to ( )10
Answer
Binary
Power Value Result
No
1 (LSB) 20 1 1x1=1
1 21 2 1x2=2
1 22 4 1x4=4
0 23 8 0x8=0
0 24 16 0x16=0
1 25 32 1x32=32
1 (MSB) 26 64 1x64=64
Question 4
(10101011)2 to ( )10
Answer
Binary
Power Value Result
No
1 (LSB) 20 1 1x1=1
1 21 2 1x2=2
0 22 4 0x4=0
1 23 8 1x8=8
0 24 16 0x16=0
1 25 32 1x32=32
0 26 64 0x64=0
Question 5
(1010.001)2 to ( )10
Answer
Integral part
Binary
Power Value Result
No
0 20 1 0x1=0
1 21 2 1x2=2
Binary
Power Value Result
No
0 22 4 0x4=0
1 23 8 1x8=8
Fractional part
Binary
Power Value Result
No
Question 6
(10100.11)2 to ( )10
Answer
Integral part
Binary
Power Value Result
No
0 20 1 0x1=0
0 21 2 0x2=0
Binary
Power Value Result
No
1 22 4 1x4=4
0 23 8 0x8=0
1 24 16 1x16=16
Fractional part
Binary
Power Value Result
No
Question 7
(1010.111)2 to ( )10
Answer
Integral part
Binary
Power Value Result
No
0 20 1 0x1=0
1 21 2 1x2=2
Binary
Power Value Result
No
0 22 4 0x4=0
1 23 8 1x8=8
Fractional part
Binary
Power Value Result
No
Question 8
(1010.0111)2 to ( )10
Answer
Integral part
Binary
Power Value Result
No
0 20 1 0x1=0
1 21 2 1x2=2
Binary
Power Value Result
No
0 22 4 0x4=0
1 23 8 1x8=8
Fractional part
Binary
Power Value Result
No
Question 1
(110101)2 - (011010)2
Answer
101001001−011010011011−100010110111000011101
Question 2
(110110)2 - (01010)2
Answer
1100110−01010101100−111000011101110000
Question 3
(101011)2 - (11101)2
Answer
100110011−11101001110−10001101011011101110
Question 4
(11111)2 - (01101)2
Answer
11111−0110110010−101110110101110
Question 5
(10000)2 - (01111)2
Answer
100101010−0111100001−1000011001100110011
Answer
115146+6412407+1125164440617
1. 6 + 1 = 7.
2. 4 + 4 = 8, as sum is equal to 8 so we will do 8 - 8 = 0. Hence, sum = 0,
carry over = 1.
3. 1 + 5 + 6 = 12, as sum is greater than 8 so we will do 12 - 8 = 4. Hence,
sum = 4, carry over = 1.
4. 1 + 1 = 2.
Question 2
Answer
5410432−25462374−542210534347264
Explanation
Question 3
Answer
11�51�+��2���87+11ACFCB5128CB7
Answer
��543�−�68�2��2−DCA2546E38BFD2
Explanation
1. F - D = 15 - 13 = 2.
2. 3 - 8, here 8 is greater than 3 so we borrow 1 from next significant digit
5 and it becomes 4. Now 3 becomes 3 + 16 = 19 and 19 - 8 = 11 or B.
3. 4 - 6, here again 6 is greater than 4 so we borrow 1 from next significant
digit D and it becomes C. Now 4 becomes 4 + 16 = 20 and 20 - 6 = 14
or E.
4. C - A = 12 - 10 = 2.
Question 5
Answer
���998�−����3���−EDA3A9BE98CCCDF
Explanation
Question 1
(4507)10
Answer
8 Quotient Remainder
8 4507 3 (LSB)
8 563 3
8 70 6
8 8 0
8 1 1 (MSB)
Question 2
(7757)10
Answer
8 Quotient Remainder
8 7757 5 (LSB)
8 969 1
8 121 1
8 15 7
8 1 1 (MSB)
Question 3
(7606)10
Answer
8 Quotient Remainder
8 7606 6 (LSB)
8 950 6
8 118 6
8 14 6
8 1 1 (MSB)
Ans: 10
8
Explanation
a = 9;
a++; // a = 10
SOP (a) // Prints 10
a -= a– – –a;
a = 10 – (10 – 8)
a = 10 -2 = 8
SOP (a) // Prints 8
c . What is the value stored in x and y after execution of these statements?
double x = Math.ceil(8.3) + Math.floor(-3.2)+Math.rint(4.5);
double y = Math.abs(Math.round(Math.max( -4.4, -9.6)));
Ans.
X = 9.0 Working: 9.0 + (-4.0) + 4.0 = 9.0
Y = 4.0 Working Math.abs(Math.round(-4.4)) = 4.0
d . Give the total number of bytes occupied by these arrays?
1.
1. int ar[25]
2. double A[12]
Ans. The number of bytes:
1.
1. ar[25] = 4*25 =100 bytes.
2. A[12] = 8*12 =96 bytes
e . What is the output of this code? Show the working
long num=729, sum 0;
for( long y= num; y> 0; y= y/10){
sum= sum + y % 10;
}
System.out.println("Sum of digits = "+ sum);
Ans.
The 1st output is= grinds ( because str1. Substring(0,2)gives “gr” & str2. Substring(1)
gives “inds”)
The 2nd output is= WHEAT ( because str1. Substring(2). toUpperCase() gives “EAT”,
so ”WH”+”EAT”= “WHEAT”)
State the method that:
i. Converts a string to a primitive float data type
ii. Determines if the specified character is an uppercase character
Ans.
i. Float.parseFloat()
ii. Character.isUpperCase()