Pageviews

Tuesday 28 July 2020

+2].2. Concept of Object Oriented Programming - Solved Questions from textbook



                                 PLUS TWO  COMPUTER SCIENCE

                                     Chapter 2. Concept of  Object Oriented Programming

                           (+2. Computer Science Questions and answers from text book)



1. State whether the following three statements are true or false 

     a. Global variables  can not be accessed in more than one function.
     
       b. Procedural programming resembles closeness to real world.

         c. In procedural programming paradigm data and functions are not bound together.

      Ans. a------    False

               b. ---------False

                 c. --------True

2. Pick the procedural language for the following

     c,c++,Java,Pascal,Fortran

    Ans. C,Pascal,Fortran

3. OOP stands for

   Ans. Object Oriented Programming

4. A blueprint for an object in OOP is called 

      Ans. Class

5. The functions associated with class are called 

    Ans. Member function

 6.  The variables declared  inside the class are  known as

      Ans. Data function

 7.  What is the difference between class and structure?

        Ans.  class combines the fields and methods(member function which defines actions) into a single unit. A structure is a collection of variables of different data types under a single unit. It is almost similar to a class because both are user-defined data types and both hold a bunch of different data types.

  8. The wrapping up of data and functions into a single unit is reffered to as

     Ans. Encapsulation

   9. Access to data is restricted by the feature is known as

   10. Objects  normally communicate with  each other through---------

          Ans. methods

    11. C++ supports ---------- and ----------binding.
 
          Ans.Late and Early binding

    12. Late binding is known as------

         Ans. Run Time polymorphism

     13. Early binding is called--------------

         Ans. Compile time POlymorhism

       14. What are the different types of inheritance.

            OOPs support the six different types of inheritance as given below :

Single inheritance.
Multi-level inheritance.
Multiple inheritance.
Multipath inheritance.
Hierarchical Inheritance.
Hybrid Inheritance.

15. What is an encapsulation?

        Ans. It is an OOP concept that binds together the data and functions that  manipulate the data and keeps both data and function outstide interference and misuse.

16. Distinguish between object and class?

      Ans.Objects:  In OOP an object  is the instance of the class, which helps programmers to use variables and methods from inside the class.Object acts like a variable of the class.Classes have logical existence.Objects have a physical existence..An object takes memory when a programmer creates one.Objects can be declared several times depending on the requirement.

Class: A class is a blueprint from which you can create the instance.A class is used to bind data as well as methods together as a single unit.A class doesn't take any memory spaces when a programmer creates one.The class has to be declared only once.

17. Define Modularity

      Ans.  A concept through which a program is partitioned into small segments called modules.

18. Distinguish between Function overloading and Operator overloading

  Ans. Function Overloading: Functions with the same name, but different signatures can act differently. Eg: The function prototypes int area (int, int); and int area(int); show that area() is an overloaded function. 
Operator overloading: It is the process of giving new meaning to an existing C++ operator.

19. What is a Hybrid inheritance?

    Ans. A hybrid inheritance is a combination of more than one types of inheritance. For example when class A and B extends class C & another class D extends class A then this is a hybrid inheritance, because it is a combination of single and hierarchical inheritance.    
Image result for what is hybrid inheritance

      20.   Draw a picture of multiple and multi level inheritance      


                          Multiple inheritance

                C++ Multiple Inheritance Example       

Multi level Inheritance


C++ multilevel inheritance