Sponsored Links


Results 1 to 4 of 4

Thread: CS304 Object Oriented Programming Assginment 6 Deadline 30 July 2010

  1. #1
    Senior Member viki's Avatar
    Join Date
    May 2010
    Posts
    2,132

    Adrive2 CS304 Object Oriented Programming Assginment 6 Deadline 30 July 2010

    Sponsored Links1


    Assignment
    Dear students in this course you have now learnt all the basic concepts of OOP and implemented it in a programming language. It is a simple assignment in which you have to answer the following:
    a) What is Static Polymorphism? Write its alternative name with a simple example.
    (2 lines for defining + single example with code)

    Sponsored Links

    b) What is Dynamic Polymorphism? Write its alternative name with a simple example.
    (2 lines for defining + single example with code)

    c) What is the main difference between Data Hiding and Data Abstraction? How we achieve it in Inheritance? (Be specific: don’t write detailed theory: give it in your own words after study)



    Warning: If any one found copied from Internet, Zero (0) marks will be awarded automatically to that ID as we shall have a strict check for plagiarism.


    What to submit?
    You have to submit the solution in a MS word file.
    Attached Files Attached Files
    Last edited by viki; 07-26-2010 at 04:05 PM.
    :o:o--------------------------------------------------------------------------------------:o:o
    [B]The more knowledge you have, the greater will be your fear of Allah.[/B]

    Please Join My [B]Group Vuhelp[/B][B], Birthday Wishing, Daily Hadees[/B] [CODE][B]http://vuhelp.net/groups/vuhelp.html[/B]
    [B]http://vuhelp.net/groups/birthday-wishing.html[/B]
    [B]http://vuhelp.net/groups/daily-hadees.html[/B][/CODE]
    [CENTER][B][COLOR="Red"][SIZE="4"]Email: [email]viki@vuhelp.net[/email][/SIZE][/COLOR][/B][/CENTER]

  2. #2
    Junior Member
    Join Date
    Aug 2010
    Posts
    1
    What is Static Polymorphism? Write its alternative name with a simple example.
    Answer:
    Static polymorphism refers to an entity existing in different physical forms simultaneously. Static polymorphism involves binding of functions based on the number, type, and sequence of arguments. The various types of parameters are specified in the function declaration, and therefore the function can be bound to calls at compile time. This form of association is called early binding. The term early binding stems from the fact that when the program is executed, the calls are already bound to the appropriate functions.

    The resolution of a function call is based on number, type, and sequence of arguments declared for each form of the function. Consider the following function declaration:

    Code:
    void add(int x , int y)
    {
    int z;
    z=x+y;
    return z;
    }
    void add(float x, float y)
    {
    float  z;
    z=x+y;
    return z;
    }
    When the add() function is invoked, the parameters passed to it will determine which version of the function will be executed. This resolution is done at compile time.
    
    
    What is Dynamic Polymorphism? Write its alternative name with a simple example
    Answer:
    Dynamic polymorphism is also known as runtime polymorphism.
    =
    It is achieved by means of virtual functions.
    -
    Depending on the type of object referred by a variable the decision about the method to be called (whether to call base class implementation or the derived class implementation) is taken at runtime.
    A member of a class that can be redefined in its derived classes is known as a virtual member. In order to declare a member of a class as virtual, we must precede its declaration with the keyword virtual:
    
        // virtual members
    #include <iostream>
    using namespace std;
    
    class CPolygon {
      protected:
        int width, height;
      public:
        void set_values (int a, int b)
          { width=a; height=b; }
        virtual int area ()
          { return (0); }
      };
    
    class CRectangle: public CPolygon {
      public:
        int area ()
          { return (width * height); }
      };
    
    class CTriangle: public CPolygon {
      public:
        int area ()
          { return (width * height / 2); }
      };
    
    int main () {
      CRectangle rect;
      CTriangle trgl;
      CPolygon poly;
      CPolygon * ppoly1 = &rect;
      CPolygon * ppoly2 = &trgl;
      CPolygon * ppoly3 = &poly;
      ppoly1->set_values (4,5);
      ppoly2->set_values (4,5);
      ppoly3->set_values (4,5);
      cout << ppoly1->area() << endl;
      cout << ppoly2->area() << endl;
      cout << ppoly3->area() << endl;
      return 0;
    }
    What is the main difference between Data Hiding and Data Abstraction? How we achieve it in Inheritance? (Be specific: don’t write detailed theory: give it in your own words after study)
    Answer:
    Abstraction: Abstraction refers to removal/reduction of irrelevant data or unnecessary data or confidential data from a Class.
    Data hiding: Data hiding is a feature provided by the abstraction for hiding the data from the class.
    Both refer to the same thing.
    Data Abstraction is that we hide the data from outside world(outside the class), i.e. making the data directly unavailable to the outside code.

    The outside code can access the data only through the member functions.

    These member functions actually specify a set of actions that can be performed on the data.
    Outside code cannot do any other operation that are not specified by the member functions.

  3. #3
    Administrator Xpert's Avatar
    Join Date
    May 2010
    Location
    Jhelum
    Posts
    6,239
    Thanks for the reply dear.

  4. #4
    Senior Member viki's Avatar
    Join Date
    May 2010
    Posts
    2,132
    so nice of u dear
    :o:o--------------------------------------------------------------------------------------:o:o
    [B]The more knowledge you have, the greater will be your fear of Allah.[/B]

    Please Join My [B]Group Vuhelp[/B][B], Birthday Wishing, Daily Hadees[/B] [CODE][B]http://vuhelp.net/groups/vuhelp.html[/B]
    [B]http://vuhelp.net/groups/birthday-wishing.html[/B]
    [B]http://vuhelp.net/groups/daily-hadees.html[/B][/CODE]
    [CENTER][B][COLOR="Red"][SIZE="4"]Email: [email]viki@vuhelp.net[/email][/SIZE][/COLOR][/B][/CENTER]

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 11-09-2010, 03:11 PM
  2. CS304 - Object Oriented Programming new quiz 8th Nov, fall 2010
    By Xpert in forum Virtual University Announcenments
    Replies: 0
    Last Post: 11-07-2010, 12:26 AM
  3. Replies: 0
    Last Post: 07-28-2010, 12:11 AM
  4. CS304 Object Oriented Programming 5 Assignment 19 July 2010
    By viki in forum Assignments & Solutions
    Replies: 0
    Last Post: 07-19-2010, 03:12 PM
  5. Replies: 0
    Last Post: 05-07-2010, 01:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft