Polymorphism Book Back Questions

11th Standard

    Reg.No. :
  •  
  •  
  •  
  •  
  •  
  •  

Computer Science

Time : 00:45:00 Hrs
Total Marks : 30
    5 x 1 = 5
  1. Which of the following refers to a function having more than one distinct meaning?

    (a)

    Function Overloading

    (b)

    Member overloading

    (c)

    Operator overloading

    (d)

    Operations overloading

  2. Which of the following reduces the number of comparisons in a program?

    (a)

    Operator overloading

    (b)

    Operations overloading

    (c)

    Function Overloading

    (d)

    Member overloading

  3. Which of the following is invalid prototype for function overloading

    (a)

    void fun (intx);
    void fun (char ch);

    (b)

    void fun (intx);
    void fun (inty);

    (c)

    void fun (double d);
    void fun (char ch);

    (d)

    void fun (double d);
    void fun (inty);

  4. Which of the following operator is by default overloaded by the compiler?

    (a)

    *

    (b)

    +

    (c)

    +=

    (d)

    ==

  5. #include< iostream >
    using namespace std;
    class Point {
    private:
    int x, y;
    public:
    point(int x1,int y1)
    {
    x=x1;y=y1;
    }
    void operator+(Point&pt3);
    void showO {cout << "x=" << x << " ,y=" << y;}
    };
    void Point::operator+(point &pt3)
    {
    x + =pt3.x;
    y+=pt3.y;
    }
    int main ()
    {
    point ptl(3,2),pt2(5,4);
    pt1+pt2;
    pt1.show ();
    return 0;
    }
    What is the output for the above program?

     

    (a)

    x=8,y=6

    (b)

    x=14,y=:14

    (c)

    x = 8, y =6

    (d)

    = x =5, y = 9

  6. 3 x 2 = 6
  7. List the operators that cannot be overloaded.

  8. class add{int x; public: add(int)}; Write an outline definition for the constructor.

  9. What is the use of overloading a function?

  10. 3 x 3 = 9
  11. What is operator overloading? Give some example of operators which can be overloaded.

  12. Discuss the benefit of constructor overloading?

  13. class sale ( int cost, discount ;public: sale(sale &); Write a non inline definition for constructor specified;

  14. 2 x 5 = 10
  15. What are the rules for operator overloading?

  16. Answer the questions based on the following program
    #include < iostream >
    #include < string.h >
    using namespace std;
    class comp {
    public:
    chars[10];
    void getstring(char str[10])
    {
    strcpy(s,str);
    }
    void operator==(comp);
    };
    void comp::operator==(comp ob)
    {
    if(strcmp(s,ob.s)==0)
    cout << "\nStrings are Equal";
    else
    cout << "\nStrings are not Equal";
    }
    int main()
    {
    comp ob, ob1;
    char string1[10], string2[10];
    cout << "Enter First String:";
    cin>>string1;
    ob.getstring(string1);
    cout << "\nEnter Second String:";
    cin >> string2;
    ob1.getstring(string2);
    ob==ob1;
    return 0;
    }
    (i) Mention the objects which will have the scope till the end of the program.
    (ii) Name the object which gets destroyed in between the program
    (iii)Name the operator which is over loaded and write the statement that invokes it.
    (iv) Write out the prototype of the overloaded member function
    (v)What types of operands are used for the overloaded operator?
    (vi) Which constructor will get executed? Write the output of the program.

*****************************************

TN 11th Standard Computer Science free Online practice tests

Reviews & Comments about 11th Computer Science Unit 15 Polymorphism Book Back Questions

Write your Comment