II Pu Cs Official (RS)
II Pu Cs Official (RS)
COMPUTER SCIENCE
I. Answer all the questions, each question carries One mark. Select the correct answer form
the choices given: 10x1 = 10
1. Which of the following is valid class declaration?
a) class A {int x}; b) class B { } c) public class C {} d) A class {};
2. Identify the syntax error in the following program segment.
Class box
{
Private : int x
};
Void main ( )
{
Box b;
}
a) Error due to semicolon missing after class definition.
b) Error due to semicolon missing at the data member declaration line
c) Error due to missing public access specifier.
d) Error due to missing protected access specifier.
3. Identify the reason for the error in the following program segment.
Class temp
{
Private : int x;
};
Void main ( )
{
Temp t;
Cout<< “enter the value of x”;
cin>>t.x;
}
a) A non member function trying to access protected data member
b) Member function trying to access private data member
c) A non member function trying to access public data member
d) The main function trying to access private data member
4. Given the class
Class box
{
Int length;
Public: int width;
Private: int height;
Void set_height (int i)
{
Height=i;
}
Void get_height( )
{
Return(height);
}
};
Public private
a) Width length, height
b) Width, length height
c) Length, height width
d) Length width, height
5. Which of the following statements are correct with respect to function overloading?
a) Functions name are same
b) Number of arguments are same
c) Number of arguments are different
d) Data type of arguments are different
6. Statement (A): Friend function is a non member function.
Statement (B): It has full access right to the private and protected members of the class.
a) A is true and B is false b) A is false and B is true
c) Both A and B are true d) Both A and B are false
7. Assertion(A): Very efficient code can be generated using inline function.
Reason(R): Inline function has complex data structure.
a) Both A and R are false b) A is true and R is false
c) Both A and R are true d) A is false and R is true
8. A pre-existing class is also called_____
a) Base class b) Derived class c) Suber class d) New class
9. If a class is derived form more than one base class then it is called as
a) Single level inheritance b) Hierarchical inheritance
c) Multiple inheritance d) Multilevel inheritance
10. ______ is not used to create objects.
a) Sub class b) Derived class c) Virtual class d) Abstract class
PART – B
II. Answer any SEVEN questions. Each question carries 5 marks: 7 x 5 = 35
11. Mention any three advantages and two disadvantages of oop.
12. Define: i) class ii) object iii) data abstraction
iv) encapsulation v) polymorphism
13. What is meant by function overloading? Explain with syntax and example.
14. What is inline function? Explain with suitable programming example.
15. Briefly explain the characteristics of friend function.
16. Explain different types of inheritance?
17. Explain single level inheritance with a suitable C++ program.
18. Mention any five applications of OOP.
PART – C
III. Answer any ONE of the following questions: 1x5=5
19. Define a class named rectangle with following criteria
1) Data members: length, breadth
2) Member functions: input( ) and output( )
3) Define member functions inside the class to input and outside length and breadth of a
rectangle
20. Define a class named sum with following conditions.
i) Data members: X and Y
ii) Member functions: input( ) and output( )
iii) Define member functions outside the class to input and output X and Y values.