php hit counter

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CS304 Object Oriented Programming Assginment 6 Deadline 30 July 2010
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support
#2
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.
Reply


Messages In This Thread
CS304 Object Oriented Programming Assginment 6 Deadline 30 July 2010 - by abrar - 08-01-2010, 05:18 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Cs403 Assignment 3 Helping material May 8,2010 viki 1 5,266 04-28-2020, 03:19 PM
Last Post: ClaireBeauc
  CS609 System Programming Assignments No. 02 Fall 2014 Due Date Dec 15, 2014 Vuhelper 1 2,273 12-13-2014, 04:25 PM
Last Post: Vuhelper
  CS201-Introduction to Programming Assignment No.2 Due Date 12 December 2014 Entboy 3 2,444 12-11-2014, 04:33 PM
Last Post: Vuhelper
  CS401 Computer Architecture and Assembly Language Programming Last Date 11 Dec 2014 Vuhelper 1 1,811 12-11-2014, 04:31 PM
Last Post: Vuhelper
  CS411 Assignment No. 02 VIsual Programming Solution and Discussion Fall 2014 Vuhelper 0 2,382 12-10-2014, 10:31 PM
Last Post: Vuhelper
  CS508 Modern Programming Languages Assignments No. 2 fall 2014 Ideal Solutions Vuhelper 0 1,958 12-05-2014, 02:31 PM
Last Post: Vuhelper
  CS304 Object Oriented Programming Assignment 02 Fall 2014 Due Date: Dec 08, 2014 Vuhelper 0 1,635 12-04-2014, 08:51 PM
Last Post: Vuhelper
  MGT201 - Financial Management Assignment No. 1 Fall 2014 Deadline Nov 26,2014 Entboy 3 2,510 11-28-2014, 12:09 AM
Last Post: viki
  CS401 Computer Architecture and Assembly Language Programming Assignment No. 01 Vuhelper 1 2,098 11-27-2014, 04:01 PM
Last Post: education-2014
  CS401 - Computer Architecture and Assembly Language Programming Assignment No 1,2014 vuassignments 1 2,947 11-24-2014, 03:31 PM
Last Post: Muhammad Hassam

Forum Jump:


Users browsing this thread: 1 Guest(s)
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support