You are on page 1of 6

Computer Science, Class XII (2017-18)

KENDRIYA VIDYALAYA KHANAPARA


(Autumn Break-2017- Holiday H.W)
1. How does a class enforce data hiding, abstraction and encapsulation? Give a suitable example using a
C++ code to illustrate the same.
2. What is the difference between the members in private visibility mode and the members in protected
visibility mode inside a class? Also, give a suitable C++ code to illustrate both. /* CBSE 2012*/
3. Differentiate between public and private visibility modes in context of Object Oriented Programming
using a suitable example illustrating each. /* CBSE 2008*/
4. Discuss the different ways by which we can declare a function in a class. Given suitable example of
each.
5. What is static data member and static member function? Give suitable example using C++ code to
illustrate them.
6. Differentiate between Private and Protected members of class in context of inheritance using C++.
/* CBSE 2007, 2008 */
7. Rewrite the following program after removing the syntactical errors (if any). Underline each correction.

#include <iostream.h> /* CBSE 2010*/


class FLIGHT
{long FlightCode; char
Description[25];
public
void AddInfo( )
{cin>>FlightCode;
gets(Description);
}
void ShowInfo
{cout<< FlightCode<<”:”<<Description<<endl;
}
};
void main( )
{FLIGHT F;
AddInfo.F( );
ShowInfo.F( );
}
8. Write the output of the following program. /*CBSE2014*/
#include<iostream.h>
class Game
{int level, score; char
Type; public:
Game(char GType='P')
{level=1; score=0; Type=GType;
}
void play(int GS);
void change();
void show()
{cout<<Type<<"@"<<level<<endl;
cout<<score<<endl;
}
};

1|Pa ge
Computer Science, Class XII (2017-18)

void main ( )
{Game A('G'), B;
B.show();
A.play(11);
A.change();
B.play(25);
A.show();
B.show();
}
void Game::change()
{Type=(Type=='P')?'G':'P';
}
void Game::play(int GS)
{score+=GS; if
(score>=30)
level=3;
else if (score>=20)
level=2;
else
level=1;
}
9. Define a class BALANCED_MEAL in C++ with following description:
Private Members:
Access number Integer
Name of Food String of 25 characters
Calories Integer
Food type String
Cost Float
AssignAccess( ) Generates random numbers
between 0 to 99 and return it.
Public Members
A function INTAKE( ) to allow the user to enter the values of Name of Food, Calories, Food type, cost
and call function AssignAccess() to assign Access number.
A function OUTPUT( ) to allow user to view the content of all the data members, if the Food type is
fruit.

10. Define a class STOCK in C++ with following description: /*CBSE2010*/


Private members
Icode of type integer (Item code)
Iname of type string (Item Name)
Price of type float (Price of each item)
Qty of type integer (Quantity in stock)
Discount of type float (Discount percentage on item)
A member function FindDisc( ) to calculate discount as per the following rule:
If Qty<= 50 Discount is 0%
If 50<Qty<= 100 Discount is 5%
If Qty>100 Discount is 10%
Public members:

2|Pa ge
Computer Science, Class XII (2017-18)

A function Buy( ) to allow user to enter values for ICode, ItemName, Price, Qty and call function
FindDisc( ) to calculate the discount.
A function ShowAll( ) to allow user to view the content of all the data members.

11. Answer the questions (i) and (ii) after going through the following class: /*CBSE 2015*/
class Passenger
{ long PNR;
char Name[20];
public:
Passenger( ) { cout<<”Ready”<<endl; } //Function1
void Book (long P, char N[ ]) // Function2
{ PNR=P; strcpy(Name,N); }
void Print ( ) // Function3
{ cout<<PNR<<Name<<endl; }

~ Passenger( ) { cout<<”Booking cancelled”<<endl; } // Function4


};
void main()
{Passenger P;
_____________ //Line1
_____________ //Line2
} //Ends here
(i) Fill in the blank statements in Line1 and Line2 to execute Function2 and Function3 respectively.
(ii) Which function will be executed at }//Ends here ? What is this function referred as?

12. Answer the following questions (i) and (ii) after going through the following class. /*CBSE 2006*/
class Exam
{ int Year;
public:
Exam( ) //Constructor 1
{ Year=2015; }
Exam(int y) //Constructor 2
{Year=y; }
Exam(Exam &t); //Constructor 3
};
(i) Create an object, such that it invokes Constructor 2.
(ii) In Object Oriented Programming, what is Constructor 1 referred as and when does it get
invoked/called? Write its calling statement.
(iii) Write complete definition for constructor 3 and what is the purpose of using it?
(iv) Which feature Object Oriented Programming is demonstrated using Constructor1,
Constructor2, and Constructor 3 in the above class text?
13. What do you mean by DBMS? Give two advantages of DBMS.
14.What is a Candidate Key, Primary Key and Alternate key? Give suitable example of each from a table
containing some meaningful data.
15. What do you understand by the terms Degree & Cardinality of a relation in relational database?
16. Explain the concept of Cartesian product between two relations, with the help of appropriate example.
17. What is a relation? What is the difference between a tuple and an attribute? /* CBSE 1998 */
18. What do you understand by selection and projection operations in relational algebra? /* CBSE 2011 */

3|Pa ge
Computer Science, Class XII (2017-18)

19. What do you mean by constraint? Give its examples. Write similarity and dissimilarity between
primary key and unique constraints.

20.What are aggregate functions? Give its example & explain any of one with an example.

21.Write SQL commands (a) to (m) and outputs (n) to (s) on the basis of Teacher relation given below:

No Name Age Department DateofJoin Salary Sex


1 Jugal 34 Computer 10-JAN-97 12000 M
2 Sharmila 31 History 24-MAR-98 20000 F
3 Sandeep 32 Maths 12-DEC-96 30000 M
4 Sangeeta 35 History 01-JUL-99 40000 F
5 Rakesh 42 Maths 05-SEP-97 25000 M
6 Shyam 50 History 27-JUN-98 30000 M
7 Manoj 44 Computer 25-FEB-97 21000 M
a) To show all information about the teachers of History department.
b) To increment the salary by 20% of those teachers who is getting salary more than 21000.
c) To display teacher name, age, department for male teachers from Teachers table.
d) To list name of female teachers who are in History department.
e) To list name and department of those teachers in which date of joining is before 24-
MAR-98 from teacher table in descending order of their name.
f) To insert a new row in teacher table with following data:
9, ‘Rahul’, 27, ‘Computer’, ’10-SEP-98’, 22500, ‘M’.
g) To list name of all teachers with their join date in descending order.
h) To show the name of those teachers who have first alphabet as ‘S’ and third alphabet as ‘n’
from teacher table.
i) To display the second largest salary from teacher table.
j) To count the numbers of those teachers who join before 12-JUL-97.
k) To decrease the salary of all teachers of Maths department by 500.
l) To find the total salary of those teachers who are working in Maths department.
m) To delete the records of those teachers whose age is greater than equal to 40.
n) select sum (Salary) from teacher where Department= ‘History’;
o) select count (distinct Department) from Teachers;
p) select avg (Salary) from Teacher where DateofJoin > ’31-JUL-97’;
q) select max (Age) from Teacher where Sex= ‘F’;
r) select count (*) from Teachers where DateofJoin < ’12-JUL-97’;
s) select name, age, department from teacher where Sex= ‘M’ ;

22.State and verify following Boolean laws.


(a). State and verify Associative Law? /* CBSE 2006, 2005 */
(b). State and verify De Morgan’s theorem. /* CBSE 2006 Comp., 2007 */
(c). State and verify Distributive Law. /* CBSE 2006 */
(d) State and verify Absorption law in Boolean- Algebra algebraically. /*CBSE 2008, 2004, 2009*/
(e). State and verify third distributive Law.

23.Verify the following algebraically: /* CBSE 2010 */


X’.Y + X.Y’ = (X’+Y’)(X+Y)
24.Name the law shown below and verify the following using a truth table: /* CBSE 2014 */
X + X’. Y = X+Y

4|Pa ge
Computer Science, Class XII (2017-18)

25.Draw a Logical Circuit Diagram for the following Boolean Expression: /* CBSE 2008 */
A . (B + C')
26.Draw the circuit diagram for the following Boolean expression :
(A+B)(A’+B)(A+B’)
27.Convert the following Boolean expression, into its equivalent Canonical Product of Sum Form(POS) :
A. B' .C + A'. B. C + A'. B. C' /* CBSE 2008 */
28.Convert the following Boolean expression into its equivalent Canonical Sum of Product Form(SOP):
(X’+Y+Z’).(X’+Y+Z).(X’+Y’+Z).(X’+Y’+Z’).
29.Write the equivalent Canonical Product of Sum Expression for the following Sum of Product Expression
F(X, Y, Z) = ∑ /* CBSE 2007 */

30.Write the equivalent expression for the following logical circuit: /* CBSE 2006 */

31.Reduce the following Boolean expression using K-Map: /* CBSE 2006 Comp. */
F(P,Q,R,S)=∑(l,3,5,8,11,12,15 )
32.Reduce the following Boolean expression using K-Map: /* CBSE 2006 */
F(P, Q, R, S) = π (0,3,5,6,7, 11, 12, 15)
33.Reduce the following Boolean expression using K - Map: /* CBSE 2009 */
H(U,V,W,Z) = (0,1,4,5,6,7,11,12,13,14,15)

5|Pa ge
Computer Science, Class XII (2017-18)

6|Pa ge

You might also like