Ticker

6/recent/ticker-posts

Class 10 Computer Engineering Object oriented Programming 2075 Solved Question Paper

SEE 2075

Group A

1.       Name any two procedure oriented programming languages.

àTwo procedural oriented programming languages are: C, Pascal, BASIC etc.

 

2.        Define encapsulation.

à The process of combining data member and member function into a single entity like class is called data encapsulation.

 

3.       What is an extraction operator?

àExtraction operator (>>) is an operator in c++ which is used with cin object to read input.

 

4.       Write syntax for creating a class.

àSyntax for creating class:
      class className{

                                Access_specifier:

                                Data_members;

                                Member_functions() {}

                                };

5.       What is static data member in a class?

à Static data member is a class members that is declared using static keyword and is shared by all objects of that class.

 

6.       What is use of inline function?

àUse of inline function is to reduce overhead of function calling.

 

7.       Write the syntax of copy constructor.

àSyntax:

ClassName (const ClassName &object_name){

//body of copy constructor

}

 

8.       What is an abstract base class?

àA class containing the pure virtual function which cannot be used to declare the objects of its own is called abstract base class.

 

9.       What is a pure virtual function?

à A pure virtual function (or abstract function) in C++ is a virtual function for which we don’t have implementation, we only declare it. A pure virtual function is declared by assigning 0 in declaration.

Example: virtual void s() = 0;

 

10.   How many arguments are required to overload a binary operator?

àOne argument is required to overload a binary operator.

11.    Name any two relational operators that can be overloaded.

àRelational operators that can be overloaded are:

·         Greater than(>)

·         Smaller than(<)

·         ==

·         <=

·         >=

 

12.   List access specifiers in C++.

àAccess specifiers in c++ are:

·         Public

·         Private

·         Protected

 

13.    Write the syntax for single inheritance.

àSyntax: class derived_class_name : access_mode base_class_name

{

//body of derived_class

 };

 

Group 'B'

14.   Differentiate between class and object.

à

Class

Object

Class is used as a template/blueprint for creating the objects.      

An object is an instance of a class.

When a class is created, no memory is allocated.

Objects are allocated memory space whenever they are created.

A class is a logical entity.

An object is a physical entity.

It is declared with the class keyword

It is created with a class name in C++

 

 

15.   Which header file must you include in a program to use 'setw' manipulator?

àI must include the <iomanip> header file to use setw manipulator

 

16.   How is the member function of a class accessed? Write the syntax.

àThe member function of a class is accessed using the direct member access (.) operator with the object of that class.

Syntax:                

                Object_name.function_name (parameters);

 

17.   WAP in C++ to convert the distance from kilometer to meter.

àThe C++ program to convert the distance form kilometer to meter is below:

#include<iostream>

using namespace std;

 

int main(){

                float disk,dism;

                cout<<"Enter the distance in kilometer: ";

                cin>>disk;

               

                dism=disk*1000;

                cout<<disk<<"kilometre = "<<dism<<"metre";

               

               

                return 0;

}

 

18.   Why do we need virtual function?

à We need virtual function to ensure that the correct function is called for an object, regardless of the type of reference (or pointer) used for function call to achieve runtime polymorphism.

 

19.   Write the syntax of an operator function for operator overloading.

àSyntax:

                Return_Type classname :: operator Operator_symbol(Argument list)

{

                                // Function Body

}

 

20.   Write any two advantages of using inheritance.

à Advantages of Inheritance:

-          It allows the code to be reused as many times as needed.

-          Saves time and effort as the main code need not be written again.

-          The base class once defined and once it is compiled, it need not be reworked.

Group 'C'

21.   Differentiate between C and C++.

à

22.   WAP in C++ to add three numbers and display the sum using class and object concept.

àProgram:

                #include<iostream>

using namespace std;

class Sum{

    public:

    int a,b,c,s;

    void Add(){

        cout<<"Enter three numbers: ";

        cin>>a>>b>>c;

        s=a+b+c;

        cout<<"The sum of three numbers is "<<s;

    }

};

int main(){

    Sum obj;

    obj.Add();

    return 0;

}

23.   What are the differences between constructor and destructor? Point outany four.

à

 

 

 

24.   How is dynamic binding useful in OOP? Explain.*

à

 

25.   WAP in C++ to overload '+' operator to concatenate two strings.

à C++ Program to overload '+' operator to concatenate two strings:

#include<iostream>

#include<string.h>

using namespace std;

class A{

                char str[20];

                public:

                                void getdata(){

                                                cout<<"Enter the string : ";

                                                cin>>str;

                                               

                                }

                                void show(){

                                                cout<<"the string is "<<str;

                                }

                                A operator + (A obj){

                                                A d;

                                                strcpy(d.str, str);

                                                strcat(d.str, obj.str);

                                                return d;

                                }

};

int main(){

                A a,b,c;

                a.getdata();

                b.getdata();

                c= a+b;

                c.show();

                return 0;

}

26.    Describe about multiple inheritance with an example.

à In this type of inheritance a single derived class may inherit from two or more than two base classes.  

 

Here, the number of base classes will be separated by a comma (‘, ‘) and access mode for every base class must be specified. A program to implement multiple inheritance in C++ is given as follows –

#include <iostream>

using namespace std;

// first base class

class Vehicle {

 public:

 Vehicle()

 {

 cout << "This is a Vehicle" << endl;

 }

};

// second base class

class FourWheeler {

 public:

 FourWheeler()

 {

 cout << "This is a 4 wheeler Vehicle" << endl;

 }

};

// derived class derived from two base classes

class Car: public Vehicle, public FourWheeler {

};

// main function

int main()

{

 // creating object of drived class will

 // invoke the constructor of base classes

 Car obj;

 return 0;

}

When the above code is compiled and executed, it produces the following result –

This is a Vehicle

This is a 4 wheeler Vehicle.

 


Reactions

Post a Comment

0 Comments