[go: up one dir, main page]

0% found this document useful (0 votes)
59 views2 pages

Cs XII Monthly Test April 2012

The document contains questions for a 12th grade Computer Science monthly test. It asks questions about object-oriented programming vs procedural programming, designing a class for a motor car with specified data members and member functions, implementing data hiding in C++ with an example, correcting errors in a C++ code snippet, explaining the need for constructors with an example, when copy constructors are called with examples, and designing a shapes class with specified data members and member functions including three constructors and a surface area calculation function.

Uploaded by

John Var
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views2 pages

Cs XII Monthly Test April 2012

The document contains questions for a 12th grade Computer Science monthly test. It asks questions about object-oriented programming vs procedural programming, designing a class for a motor car with specified data members and member functions, implementing data hiding in C++ with an example, correcting errors in a C++ code snippet, explaining the need for constructors with an example, when copy constructors are called with examples, and designing a shapes class with specified data members and member functions including three constructors and a surface area calculation function.

Uploaded by

John Var
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

KENDRIYA VIDYALAYA, BELLARY XII COMPUTER SCIENCE MONTHLY TEST Max. Marks 25 1.

Explain the difference between Object Oriented Programming and Procedural Programming (3) 2. Design a class motor_car having the following specifications: Data Members: License number Car Manufacturer Car Model Number Bought On Price Speed Member Functions: Getdata() Get the license number, manufacturer, model number Car_Bought() Get the buying data and the price Start_car() Gets the speed of the car Accelerate() Increase the speed of the car by 4m/s

(4)

3. Explain using a suitable example how data hiding/encapsulation is implemented in C++. (4) 4. Identify and correct the error in the following piece of code. Underline your corrections: #include<iostream.h> #include<stdio.h> class employee { privat: int empno; char name[25]; double salary; void getdata() { cin >> Enter employee number : ; Cout << empno; Cin >> Enter name; gets(name): Cin >> Enter salary : ; cout >> salary; } Void inc_sal(double x) { Employee.salary += double } int display();

}; Void main() { Employee.getdata(); Employee.inc_sal(); Employee.display(); } (4)

5. Explain the need for constructors with example. 6. When are copy constructors called. Explain with examples.

(3) (3)

7. Design a class shapes with the following specification: Data Members: It should contain three variables which can hold three floating point values dim1, dim2, dim3. A string should also be there to hold which of the shapes Circle, Rectangle, Parallelopiped. Member Functions: Define three constructors. First Constructor should accept only one float parameter and it should set dim1 to the parameter and set the shape to Circle Second constructor should accept two float parameters and it should set dim1,dim2 to the parameters and set the shape to Rectangle Third constructor should accept three float parameters and it should set dim1, dim2, dim3 to the three parameters and also set the shape to Parallelopiped Member function surface_area() calculates the surface area depending on the shapes. Circle=pi*radius*radius, Rectangle=length*breadth, Parallelopiped=2(l*b+b*h+l*h) (4)

You might also like