
Computer Science ISC 12th - paper 2
Quiz by Sujatha Rajkumar
Tag the questions with any skills you have. Your dashboard will track each student's mastery of each skill.
1. Given the Boolean expression F = ( P + R) · ( P·Q + Q·R’ ),identify
(a) the complement of the expression [2]
2. 26Thefollowing public method is a part of some class, Assume that both theparameters x and y are positive integers. Answer the questions following it
intAfunction(int x, int y)
{
intp=1,n=x;
while(y>0)
{
if(y%2==1)
P*=n;
y/=2
n*=n;
}
returnp;
}
What will be returned by Afunction(2,7) [2]
3. The following public method is a part of some class, Assume that both the parameters x and y are positive integers. Answer the questions following it
int A function (int x, int y)
{
intp=1,n=x;
while(y>0)
{
if(y%2==1)
P*=n;
y/=2
n*=n;
}
returnp;
}
State that what is being done by Afunction(int,int) in general [1]
4. withreference to the code given below answer the questions that follow
voidshow(int n, int d)
{
While(n>1)
{
if(n%d==0)
{
System.out.print(“\t”+d);
n=n/d;
}
else
d++;
}
}
What is the output of function show (24,2) [2]
5. withreference to the code given below answer the questions that follow
voidshow(int n, int d)
{
While(n>1)
{
if(n%d==0)
{
System.out.print(“\t”+d);
n=n/d;
}
else
d++;
}
}
State what is being computed by show(x,y) [1]
6. withreference to the program code given below
voiddimen(int n[][])
{
intt=0;
for(inti=0;i<n.length;i++)
{
for(intj=0;j<n[0].length;j++)
{
if(i==j)
t=t+n[i][j];
}
}
System.out.println(t)
}
What will be the output of the method dimen() when the value of [2]
n[][]={{1,2,3},{3,4,5},{6,7,8}}
7. withreference to the program code given below
voiddimen(int n[][])
{
intt=0;
for(inti=0;i<n.length;i++)
{
for(intj=0;j<n[0].length;j++)
{
if(i==j)
t=t+n[i][j];
}
}
System.out.println(t)
}
What is the method dimen() performing [1]
8. with reference to the program code given below ,answer the questions that follow
voidsolve(int x[])
{
intsum=0;
for(inti=0;i<x.length;i++)
{
sum=sum+(x[i]*x[i]);
}
System.out.println(sum);
}
}
What will be the output of the method solve()when the value of
x[]={1,2,3,4,5} [2]
9. with reference to the program code given below ,answer the questions that follow
voidsolve(int x[])
{
intsum=0;
for(inti=0;i<x.length;i++)
{
sum=sum+(x[i]*x[i]);
}
System.out.println(sum);
}
}
what is the method solve() performing [1]
10. With reference tothe program code below , Answer the question that follows
intdec=0, c=0;
intperform(long n)
{
while(n>0)
{
intd=(int)n%10;
dec=dec+d*(int)Math.pow(2,c++);
n=n/10;
}
returndec;
}
What will be returned by the method perform(1110) [2]
11. .With reference to the program code below , Answer the question that follows
int dec=0, c=0;
int perform(long n)
{
while(n>0)
{
intd=(int)n%10;
dec=dec+d*(int)Math.pow(2,c++);
n=n/10;
}
return dec;
}
What is the method perform() doing [1]
12. The following function is a part of some class which computes and returns the greatest common divisor of any two numbers. There are some places inthe code marked by ?1?, ?2?, ?3?, ?4? and ?5? which must be replaced by statement/expression so that the function works correctly0
intgcd(int a, int b)
{
intr.
while(?1?)
{
r= ?2?;
b= ?3?;
a= ?4?
}
if(a ==0)
return?5?;
else
return-1;
}
What is the expression or statement at ?1? [1]
13. The following function is a part of some class which computes and returns the greatest common divisor of any two numbers. There are some places in the code marked by ?1?, ?2?, ?3?, ?4? and ?5? which must be replaced by statement/expression so that the function works correctly0
intgcd(int a, int b)
{
intr.
while(?1?)
{
r= ?2?;
b= ?3?;
a= ?4?
}
if(a ==0)
return?5?;
else
return-1;
}
What is the expression or statement at ?2? [1]
14. The following function is a part of some class which computes and returns the greatest common divisor of any two numbers. There are some places in the code marked by ?1?, ?2?, ?3?, ?4? and ?5? which must be replaced by statement/expression so that the function works correctly0
intgcd(int a, int b)
{
intr.
while(?1?)
{
r= ?2?;
b= ?3?;
a= ?4?
}
if(a ==0)
return?5?;
else
return-1;
}
What is the expression or statement at ?3? [1]
15. With reference to the program code below , Answer the question that follows
intdec=0, c=0;
intperform(long n)
{
while(n>0)
{
intd=(int)n%10;
dec=dec+d*(int)Math.pow(2,c++);
n=n/10;
}
return dec;
}
What is the expression or statement at ?4? [1]
16. The following function is a part of some class which computes and returns the greatest common divisor of any two numbers. There are some places in the code marked by ?1?, ?2?, ?3?, ?4? and ?5? which must be replaced by statement/expression so that the function works correctly0
intgcd(int a, int b)
{
intr.
while(?1?)
{
r= ?2?;
b= ?3?;
a= ?4?
}
if(a ==0)
return?5?;
else
return-1;
}
Whatis the expression or statement at ?5? [1]
17. The following program code searches for an element in a single dimensional array using binary search technique there are some places in the code marked as ?1?,?2?,?3?.?4?,?5? , which are to be replaced by a statement or an expression so that the code works properly
publicvoid main()
{
inta[]={10,20,30,40,50,60,70,80,90,100}// arranged in order
inti, left=0, right=a.length-1, mid=0,ns;
intflag=0, pos=0;
System.out.println("enterthe element to be searched");
ns=Integer.parseInt(br.readLine());
while(left<=right)
{
mid=??1??/2;
if(ns==???2????)
{
flag=0;
pos=mid;
break;
}
else
if(???3???>a[mid])
left=????4????;
else
if(ns<a[mid])
{???5???=mid-1;
}
}
if(flag==1)
System.out.println("elementfound at"+mid+" position");
else
System.out.println("elemntnot found");
}
Answerthe following questions
What is the statement or expression at ?1? [1]
18. The following program code searches for an element in a single dimensional array using binary search technique there are some places in the code marked as ?1?,?2?,?3?.?4?,?5? , which are to be replaced by a statement or an expression so that the code works properly
publicvoid main()
{
inta[]={10,20,30,40,50,60,70,80,90,100}// arranged in order
inti, left=0, right=a.length-1, mid=0,ns;
intflag=0, pos=0;
System.out.println("enterthe element to be searched");
ns=Integer.parseInt(br.readLine());
while(left<=right)
{
mid=??1??/2;
if(ns==???2????)
{
flag=0;
pos=mid;
break;
}
else
if(???3???>a[mid])
left=????4????;
else
if(ns<a[mid])
{???5???=mid-1;
}
}
if(flag==1)
System.out.println("elementfound at"+mid+" position");
else
System.out.println("elemntnot found");
}
Answer the following questions
What is the statement or expression at ?2? [1]
19. The following program code searches for an element in a single dimensional array using binary search technique there are some places in the code marked as ?1?,?2?,?3?.?4?,?5? , which are to be replaced by a statement or an expression so that the code works properly
publicvoid main()
{
inta[]={10,20,30,40,50,60,70,80,90,100}// arranged in order
inti, left=0, right=a.length-1, mid=0,ns;
intflag=0, pos=0;
System.out.println("enterthe element to be searched");
ns=Integer.parseInt(br.readLine());
while(left<=right)
{
mid=??1??/2;
if(ns==???2????)
{
flag=0;
pos=mid;
break;
}
else
if(???3???>a[mid])
left=????4????;
else
if(ns<a[mid])
{???5???=mid-1;
}
}
if(flag==1)
System.out.println("elementfound at"+mid+" position");
else
System.out.println("elemntnot found");
}
Answerthe following questions
What is the statement or expression at ?3? [1]
20. Thefollowing program code searches for an element in a singledimensional array using binary search technique there are someplaces in the code marked as ?1?,?2?,?3?.?4?,?5? , which are to bereplaced by a statement or an expression so that the code worksproperly
publicvoid main()
{
inta[]={10,20,30,40,50,60,70,80,90,100}// arranged in order
inti, left=0, right=a.length-1, mid=0,ns;
intflag=0, pos=0;
System.out.println("enterthe element to be searched");
ns=Integer.parseInt(br.readLine());
while(left<=right)
{
mid=??1??/2;
if(ns==???2????)
{
flag=0;
pos=mid;
break;
}
else
if(???3???>a[mid])
left=????4????;
else
if(ns<a[mid])
{???5???=mid-1;
}
}
if(flag==1)
System.out.println("elementfound at"+mid+" position");
else
System.out.println("elemntnot found");
}
Answerthe following questions
What is the statement or expression at ?4? [1]
21. The following program code searches for an element in a single dimensional array using binary search technique there are some places in the code marked as ?1?,?2?,?3?.?4?,?5? , which are to be replaced by a statement or an expression so that the code works properly
publicvoid main()
{
inta[]={10,20,30,40,50,60,70,80,90,100}// arranged in order
inti, left=0, right=a.length-1, mid=0,ns;
intflag=0, pos=0;
System.out.println("enterthe element to be searched");
ns=Integer.parseInt(br.readLine());
while(left<=right)
{
mid=??1??/2;
if(ns==???2????)
{
flag=0;
pos=mid;
break;
}
else
if(???3???>a[mid])
left=????4????;
else
if(ns<a[mid])
{???5???=mid-1;
}
}
if(flag==1)
System.out.println("elementfound at"+mid+" position");
else
System.out.println("elemntnot found");
}
Answer the following questions
What is the statement or expression at ?5? [1]
22. The law which represents the Boolean equation p => q = p’ + 1 is:
23.Which of the following is a universal gate?
24. To perform product of max terms Boolean function must be brought into
25. According to the Boolean algebra absorption law, which of the following is correct?
26. Q5. When the inputs are A=0, B=1, C=1 and D=0, choose the MAXTERM from the following:
27. Full Adder combinational circuits has 3 inputs and
28. DeMorgan’s theorem states that _______________
29. If (~P => Q) then choose the inverse from the following.
30. The logic gate that provides high output for same inputs ______________
31. Reduce the given Boolean function F(A,B,C,D)=€( 0, 3, 4, 7, 8, 11, 12, 15) by using 4-variable Karnaugh map and answer the following questions:
a. What will be the least number of groups and their types formed for reduction?
32. Q29. What is the output of the statements given below?
a. System.out.print('D'+'9'+'9'+'Z');
33. What is the output of the statements given below?
b. System.out.print(‘z’+’Z’):