Compare run-time and compile-time polymorphism.

1 Answer

Answer :

Compare run-time and compile-time polymorphism.

image

Related questions

Description : Write any four differences between compile time and run time polymorphism.

Last Answer : Sr. No. Compile-time Polymorphism Run-time Polymorphism 1 Compile time polymorphism means that an object is bound to its function call at compile time. Run time polymorphism means that selection ... binding. 7 E.g. overloaded function call. E.g. virtual function.

Description : How to achieve compile time polymorphism explain in detail.

Last Answer : The process of linking of function call to function definition at compile time is called as Compile Time Polymorphism. It can be through Function and operator overloading. Function overloading: The process of defining the ... \n Concatenated String is:"; str1.display(); getch(); }  

Description : What is polymorphism? Enlist different types of polymorphism. What are the differences between them?

Last Answer : Polymorphism: It is a feature of object oriented programming which allows a programmer to have a more than one function having same name but different /same parameters but performs different/ ... Compile Time polymorphism o Virtual Function Difference between Types of Polymorphism:

Description : Polymorphism is implemented using function overloading. Justify the statement.

Last Answer : Polymorphism is a mechanism that allows a developer to have more than one function with same name but different signature. In function overloading, one can make use of more than one function with different signature as well. Hence ... main()  { int a[10],i,isum; float b[5],fsum; clrscr(); cout

Description : Define polymorphism. Enlist its types.

Last Answer : Definition: Polymorphism means ability to take more than one form that means a program can have more than one function with same name but different behavior. Types of polymorphism: 1) Compile time polymorphism 2) Runtime polymorphism 

Description : Define the following terms: (i) Data abstraction (ii) Class (iii) Dynamic binding (iv) Polymorphism

Last Answer : (i) Data abstraction: Abstraction refers to the act of representing essential features without including the background details or explanation. Data abstraction is the process of defining a data type, often ... more than one form at different instances depending on the type or number of arguments. 

Description : With suitable example, describe use of virtual function in polymorphism.

Last Answer : In order to achieve polymorphism, objects belonging to different classes should be able to respond to the same message at different instances which initiates the use of single pointer variable to refer to objects of ... void accept() { coutroll; coutname; } virtual void display() { cout

Description : Define what is the difference between compile-time polymorphism and run-time polymorphism?

Last Answer : Compile time Polymorphism Compile time Polymorphism also known as method overloading. Method overloading means having two or more methods with the same name but with different signatures. Run time ... or more methods with the same name, same signature but with a different implementation.

Description : Differentiate between run time and compile time polymorphism.

Last Answer : Sr. No. Compile time polymorphism Runtime polymorphism 1 In this polymorphism, an object is bound to its function call at compile time. In this polymorphism, ... is implemented with operator overloading or function overloading It is implemented with virtual function.

Description : Write a program which concate and reverse string by using pointer to string.

Last Answer : #include #include void main()  { char str1[20], str2[20], rev[20],*p1,*p2; int cnt=0; clrscr(); coutstr2;  p1=&str1[0];  p2=&str2[0]; while(*p1!='\0')  { p1++;  } while(*p2!='\0')  { *p1=*p2; p1++; p2++;  }  *p1='\0'; cout

Description : What is constructor? How user can declared constructor in derived class? Explain with example.

Last Answer : Constructor:- Constructor is a special member function which has same name as a class name and is used to initialize object during compile time of program. Declaring constructor in derived class If a base class contains a ... derived d(2,5); d.displaybase(); d.display(); getch(); }

Description : What is function? What is call by value? What is call by reference? What is the difference between them?

Last Answer : Function: A function is a group/set of statements/instruction that performs a specific task. It can be system defined i.e. clrscr(), getch(), or user defined i.e. add(), sub(). ... reflected inside as well as outside the function. Difference between Call by Value and Call by Reference:

Description : Write a program which perform arithmetic operation using pointer.

Last Answer : #include<iostream.h> #include<conio.h> void main() { int num[5]={56,75,22,18,90}; int ptr; int i; cout<< array elements are:: ; for(i=0;i<5;i++) ptr=num; cout<< ... 3; cout<< value of ptr+=3:: <<*ptr; cout<< \n ; getch(); }

Description : How to define virtual function? Give example.

Last Answer : A virtual function is a member function that is declared within a base class and redefined by a derived class. To define virtual function following syntax is used: Class baseclass { virtual function_name() { } ... } }; Example: #include class Base { public: virtual void show( ) { cout

Description : What is structure? How user declare structure? Give example.

Last Answer : Structure is a collection of different data types written under a common name. It is a user defined data type. To Define a structure following Syntax is use:- struct structure_name { data_type variable 1; data_type ... () {  Person p1; cout>p1.name; cout> p1.age; cout> p1.salary; cout

Description : What is copy constructor? Explain with example.

Last Answer : Copy constructor: The copy constructor is a constructor which creates an object by initializing it with an object of the same class, which has been created previously. The copy constructor is used to: ... ; // Copy constructor is called here // Let us access values assigned by constructors cout

Description : Explain how to pass object as function argument.

Last Answer : An object may be used as function arguments in two methods:- i) A copy of the entire object is passed to the function. ii) Only the address of the object is transferred to the function. 1) Pass-by-value Since a copy ... (int h, int m) { hours = h; minutes = m; } void puttime(void)  { cout

Description : Explain the derived class access by pointer.

Last Answer : When base class and its derived class both contains same function name then the function in base class is declared as virtual using keyword virtual preceding its normal declaration. When a function is made virtual, C ... . Example: #include class Base { public: virtual void show( ) { cout

Description : Write a program which implement the concept of overloaded constructor.

Last Answer : #include #include class integer { int m,n; public: integer() { m=0; n=0; } //default constructor 1 integer(int a, int b) { m=a; n=b; } //Parameterized constructor 2 integer(integer &i) { m=i.m; n=i.n; } //copy constructor 3 }; void display() { cout

Description : Explain different operator used in C++.

Last Answer : :: Scope resolution operator: This operator allows access to the global version of a variable. Scope resolution operator is also used in classes to identify the class to which a member function belongs. :: ... and assigns it to the variable on its right. It is used with cin statement to input data.

Description : Explain the need of static member function with example.

Last Answer : A static member function can have access to only other static members (functions or variables) declared in the same class. A static member function can be called using the class name as follows: class_name:: ... test::showcount(); -------------Call to static member function. }

Description : Write down characteristics of object oriented programming.

Last Answer : Characteristics of object oriented programming are: Emphasis is on data rather than procedure. Programs are divided into objects. Data structures are designed such that they characterize the ... can be easily added whenever necessary. Follows bottom-up approach in program designing. 

Description : What is base class? What is derived class? Give example.

Last Answer : Base class: In inheritance a new class is derived from an old class. The old/existing class is referred as base class whose properties can be inherited by its derived class. Derived class: In inheritance a new ... as well as base class. Example: class base { public: void putb() { cout

Description : What is pure virtual functions? Write down the rules used for pure virtual function.

Last Answer : A pure virtual function is a function which is declared in a base class and which does not have definition relative to the base class. In such cases, the compiler requires each derived class to either ... A class containing pure virtual functions cannot be used to declare any objects of its own.  

Description : What is destructor? How destructor is declared? When destructor is invoked?

Last Answer : Destructor: A destructor is a special member function used to destroy the objects that are created by a constructor. Declaration: Destructor is declared in public section of a class. It is member function ... from the program (or block or function) to clean up storage that is no longer accessible. 

Description : What is multiple inheritance? What is multilevel inheritance? What is difference between them?

Last Answer : Multiple Inheritance: When A derived class is derived from more than one base class then it is known as multiple inheritance. A derived class can inherit the attributes of all base classes ... , last derived class will inherit only public property of all class including intermediate class.

Description : What is parametrized constructor? Explain with example.

Last Answer : A constructor that can take arguments is known as parameterized constructor. In some applications, it may be necessary to initialize the various data members of different objects with different values when they ... object is created. Member function put displays the value of data member m . 

Description : What do you mean by overloaded constructor?

Last Answer : When more than one constructor function is defined in a class, it is referred as overloaded constructor. Each overloaded constructor function is invoked with respect to arguments pass in the function call.

Description : Write a program to find whether the string is palindrome or not.

Last Answer : #include #include #include void main() { char str1[10],str2[10]; int c; clrscr(); coutstr1; strcpy(str2,str1); strrev(str2); cout

Description : Write a program for multiple inheritance. 

Last Answer : #include #include class base1 { public: void show1() { cout

Description : Write a program to show object as function argument. 

Last Answer : #include<iostream.h> #include<conio.h> #include<string.h> class objarg  { char str[10]; public: void get() { cout<<"\n Enter a Message"; cin>>str; } void ... clrscr(); o1.get(); o2.copy(o1); o2.display(); getch();  }

Description : What is the need of virtual function? Explain with example.

Last Answer : When base class and its derived class both contain same name and prototype member function then derived class function overrides base class function. Base class pointer is used to refer member functions of its ... Program/Example: #include class Base { public: virtual void show( ) { cout

Description : Give four differences between object oriented programming and procedure oriented programming.

Last Answer : Give four differences between object oriented programming and procedure oriented programming.

Description : State characteristic of static data member. Explain why static data member must be defined outside the class. 

Last Answer : Characteristics of static data members: 1. It is initialized to zero when the first object of its class is created. No other initialization is permitted. 2. Only one copy of that member is created ... member(s) it is necessary to make static members global and re-declared outside of the class.

Description : Explain the following with syntactic rules: (i) public inheritance (ii) protected inheritance.

Last Answer : (i) public inheritance: i) When the visibility-mode is public the base class is publicly inherited. ii) In public inheritance, the public members of the base class become public members of the derived class and ... variables; Member function; }; class B : protected A { Members of class B };

Description : Explain the concept of memory allocation for object.

Last Answer : The memory space for object is allocated when it is declared & not when the class is specified. The member functions are created & placed in memory space only once when they are defined as a ... (object 1, object 2, object 3) has its own separate memory space for its member variables.

Description : Give the syntax and use of following with respect to (i) get() (ii) put().

Last Answer : (i) get() function: The get() function is member of istream class. It is used to read a single character from the keyboard. Syntax of get() function: get(variable_name); example:  char c; ... /variable_name); example: cout.put( X ); The above example displays character X on the screen.

Description : Write a program to declare class student having data members name and percentage. Write constructor to initialize these data members. Accept and display this data for one object.

Last Answer : #include<iostream.h> #include<conio.h> #include<string.h> class student { char name[20]; float per; public: student(char n[],float p) { strcpy(name,n); per=p; } ... { student S("Sachin",78.00); clrscr(); S.putdata(); getch(); }

Description : What is abstract class? Give one example of abstract class.

Last Answer : An abstract class is a class that is designed only to act as base class. It is not used to create objects. An abstract class is used to define an implementation and is intended to be inherited by child classes. Example: ... >a; } void display() { coutb; } void display1()  { display(); cout

Description : Differentiate between call by value and call by reference method.

Last Answer : Call by Value Call by reference In call by value, a copy of actual arguments is passed to respective formal arguments. In call by reference, the location, that is, the address of actual arguments is ... ;a,&b); //function call void swap(int *a,int *b)// function definition { }

Description : Write a program to copy content of one string to another string using pointer to string.

Last Answer : #include<iostream.h> #include<conio.h> void main() { char str1[10],str2[10],*p1,*p2; clrscr(); cout<<"\n Enter a String"; cin>>str1; p1=&str1[0]; p2= ... } *p2='\0'; cout<<"Copied String is "<<str2; getch(); }

Description : Write a program for overloading of ++unary operator for inch to feet conversion. 12 inch = 1 feet.

Last Answer : #include #include class abc { int i,f; public: abc(int f1,int i1) { f=f1; i=i1; } void operator ++() {  while(i>11)  {  f++;  i=i-12;  }  cout

Description : What is inheritance and explain visibility modes in detail.

Last Answer : Inheritance: The mechanism of deriving new class from an old (existing) class is called as inheritance. With inheritance, one class acquires the properties of objects of other classes. ... members of derived class and public members of base class becomes public members of derived class.

Description : Explain data encapsulation and data abstraction.

Last Answer : Data encapsulation: The wrapping up of data and function into a single unit (called class) is known as encapsulation. The data is not accessible to the outside world, and only those functions ... as they hold information. The functions that operate on these data are called as member functions.

Description : Write a program to swap two integer values by using call by reference.

Last Answer : #include #include void swap(int *a,int *b) { int c; c=*a; *a=*b; *b=c; } void main() { int a,b; couta; coutb; cout

Description : Why friend function is required? Give four characteristics of friend function.

Last Answer : Friend function: Private members of a class cannot be accessed from outside the class. A non-member function cannot have an access to the private data of a class. Sometimes, two classes may need to ... part of a class without affecting its meaning. 6. Usually it has the objects as the arguments.

Description : List features of procedure oriented programming.

Last Answer : Features of procedure oriented programming: 1. Emphasis is on doing things (algorithms). 2. Large program are divided into smaller programs known as functions. 3. Most of the functions share global ... transform data from one form to another. 6. Employs top -down approach in program design.

Description : Write a program to implement single inheritance. Declare base class employee with Emp_No. and Emp_Name. Declare derived class fitness with height and weight. Accept and display data for one employee.

Last Answer : #include<iostream.h> #include<conio.h> class employee { protected: int emp_no; char emp_name[10]; public: void gete() { cout<< enter employee details ; cin>>emp_no; cin>> ... f.gete(); f.pute(); f.getft(); f.putft(); getch(); }

Description : Explain concept of function overriding with example.

Last Answer : Function Overriding:- When derived class defines same name function, as defined in its base class then it is called as function overriding. In this a function in the derived class overrides the inherited function. Example : #include #include class Base { public: void Display() { cout

Description : Describe multiple constructor by giving example.

Last Answer : Multiple constructor: Multiple constructors is a category of constructor in which a class can have more than one constructor. This is also known as constructor overloading. All constructors are defined with the same name as the class ... constructor 1 integer(int a, int b) { m = a; n = b; cout