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

1 Answer

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 called abstract data type (ADT), together with the principle of data hiding.

(ii) Class: Class is a collection of objects of same data types. Class contents data and functions that operate on data.

(iii) Dynamic binding: Linking of function call to function definition at run time is defined as dynamic binding 

(iv) Polymorphism: Polymorphism means ability to take more than one form at different instances depending on the type or number of arguments. 

Related questions

Description : Describe following terms: Inheritance, data abstraction, data encapsulation, dynamic binding.

Last Answer : Inheritance: 1. Inheritance is the process by which objects of one class acquire the properties of objects of another class. 2. It supports the concept of hierarchical classification. It also provides the ... with a given procedure call is not known until the time of the call at run-time.

Description : Differentiate between static binding and dynamic binding.

Last Answer : Sr. No. Static binding Dynamic binding 1 The linking of function call to function definition at compile time is known as static binding The linking of function call ... 5 Implemented with Function overloading and operator overloading Implemented with virtual function

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 : 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 : 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 : Compare run-time and compile-time polymorphism.

Last Answer : Compare run-time and compile-time polymorphism.

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 : 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 : 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 : What is dynamic memory allocation? Explain with example.

Last Answer : Allocating memory at run time (when program is in execution) is called as dynamic memory allocation. Dynamic memory allocation use malloc ( ) and calloc ( ) functions to allocate memory at run time. C++ supports these ...  sample *ptr=new sample;  ptr->getdata();  ptr->putdata(); }

Description : How to define a member function outside the body of class? 

Last Answer : The user can declare member function outside the class with the help of scope resolution operator (::). The label class_name:: tells the compiler that the function_name belongs to the class class_name. ... In above example accept() member function of class student is defined outside of the class. 

Description : Define 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.

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 : 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 : 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 : Write a program to declare class having data member as hrs, mins, secs. Write constructor to assign values and destructor to destroy values. Accept & display data for one object.

Last Answer : #include<iostream.h> #include<conio.h> class time { private: int hrs, mins,sec; public: time(int h,int m,int s) { hrs=h; mins=m; sec=s; } ~time() { cout<< hours ... } }; void main() { time t(2,43,56); t.display(); getch(); }

Description : Write a program to declare a class 'staff' having data members as name and department. Accept this data for 10 staffs and display names of staff that are in 'CO' department.

Last Answer : #include<iostream.h> #include<conio.h> #include<string.h> class staff {  char name[10], dept[10];  public:  void accept() { cout<<"Enter Name and Department:\t"; cin>> ... i=0;i<=10;i++) { s[i].display(); } getch(); }

Description : Implement a program to declare a class city with data members city name and state. Accept and display data for 1 object using pointer to object.

Last Answer : #include<iostream.h> #include<conio.h> class city { char city_name[20],state[20]; public: void accept() { cout<<"\nEnter city data:"; cout<<"\nName:"; ... ); ptr=&c; ptr->accept(); ptr->display(); getch(); }

Description : Write a program in C++ to declare a class „Journal‟ having data members as journal_nm, price, ISSN_No. Accept this data for two objects and display the name of the journal having greater price.

Last Answer : #include<iostream.h> #include<conio.h> class Journal { char journal_nm[20]; int ISSN_No; float price; public: void accept(); void display(Journal); }; void Journal::accept() { ... clrscr(); j1.accept(); j2.accept(); j1.display(j2); getch(); }

Description : Write a program in C++ to declare a class measure having data members as add 1, add 2, add 3. Initialize the values of two data members using constructor and display their addition using function.

Last Answer : #include<iostream.h> #include<conio.h> class measure { public: int add1,add2,add3; measure(int a,int b) { add1=a; add2=b; } void cal() { add3=add1+add2; } void display() ... ;>a>>b; measure m1(a, b); m1.cal(); m1.display(); getch(); }

Description : Which of the following cloud concept is related to pooling and sharing of resources? a) Polymorphism b) Abstraction c) Virtualization d) None of the mentioned

Last Answer : Virtualization

Description : Which of the following cloud concept is related to pooling and sharing of resources? a) Polymorphism b) Abstraction c) Virtualization d) None of the mentioned

Last Answer : Virtualization

Description : Which of the following cloud concept is related to pooling and sharing of resources? a) Polymorphism b) Abstraction c) Virtualization d) None of the mentioned

Last Answer : Virtualization

Description : Module design is used to maximize cohesion and minimize coupling. Which of the following is the key to implement this rule? (A) Inheritance (B) Polymorphism (C) Encapsulation (D) Abstraction

Last Answer : (C) Encapsulation

Description : Define with respect to FET:- (i) Static drain resistance (ii) Dynamic resistance (iii) Trans conductance (iv) Pinch-off voltage

Last Answer : (i) Static drain resistance- It is the ratio of drain source voltage (ΔVDS) to the drain current (ID) at constant gate-source voltage. It can be expressed as, Rd = (VDS)/(ID) at ... of charge carrier and the value of drain current reaches its constant saturation value is called pinch off voltage.

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 : 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 : 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 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 : Write a program to implement the concept of virtual base class for following figure. Accept and display information of one employee with his name, code, basic pay, experience and gross salary with the object of employee class.

Last Answer : #include<iostream.h> #include<conio.h> class Master  {  char name[10],code[3];  public:  void acceptM() { cout<<"\nEnter name and code "; cin>>name>>code; ... .displayM(); e.displayA(); e.displayD(); e.displayE(); getch();  }

Description : Differentiate between function definition inside and outside the class

Last Answer : Sr. No Inside function definition Outside function definition  1 A member function of a class is defined inside the class. A member function of a class is declared inside class and as defined outside the ... }; void item :: getdata(int a, float b) { number = a; cost = b; }

Description : Explain pointer to derived class with example.

Last Answer : Pointers can be used to point to the base class objects and objects of derived class. Pointers to objects of base class are compatible with pointers to objects of a derived class. Single pointer variable can be made to point ... { int a; public:  void get() { couta; }  void put() { cout

Description : Explain the concept of overloaded constructor in a class with suitable example.

Last Answer : Overloaded constructor: When more than one constructor function is defined in a same class then it is called as overloaded constructor. All constructors are defined with the same name as ... first constructor does not accept any argument and the second constructor accepts two integer arguments.

Description : Explain constructor in derived class with suitable example.

Last Answer : When a class is declared, a constructor can be declared inside the class to initialize data members. When a base class contains a constructor with one or more arguments then it is ... one argument. Derived class constructor accepts two values and passes one value to base class constructor.

Description : Explain class with suitable example.

Last Answer : A class is a user defined data type which binds data and its associated functions together. It allows the data and functions to be hidden, if necessary from external use. Generally, a class ... for displaying their values. These functions provide the only access to data members of the class. 

Description : Explain multiple constructors in a class with suitable example. 

Last Answer : Multiple constructors in a class means a class can contain more than one constructor. This is also known as constructor overloading. All constructors are defined with the same name as the class they belong to. All the ... default constructor integer(int a, int b) { m = a; n = b; cout

Description : Differentiate between class and structure.

Last Answer : Class Structure 1. Class is user defined data type. It's a way of binding data and functions together in one single unit. It is a collection of data members and member functions. 1. Structure contains ... void putdata(); }; for e.g. struct student { introll_no; char name[20]; }s;

Description : Describe syntax and use of defining member function outside class. Give one example.

Last Answer : Member function that is declared inside a class has to be defined separately outside the class. These member functions associate a membership identify label in the header. This label tells the ... ) A member function can call another member function directly, without using the dot operator. 

Description : Describe with example importance of virtual base class.

Last Answer : A virtual base class (Grandparent class) is a class that avoids duplication of inherited data in derived class (child class) derived from parent classes (parent1 and parent2) which in turn derived ... duplications class L is declare as virtual base class while defining base classes B1 and B. 

Description : State and describe access specifiers used inside class to declare members.

Last Answer : Access specifiers: 1. private 2. protected 3. public Private access specifier: Class members declared as private can be accessed only from within the class. Outside class access is not allowed for private members of ... { private: int a; protected: int b; public: void display() { cout

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 : Define constructor. State any two types of constructor.

Last Answer : Definition: A constructor is a special member function whose task is to initialize the objects of its class. Types of constructor: 1) Default constructor 2) Parameterized constructor 3) Copy Constructor 4) Constructor with default value 5) Multiple constructor/overloaded constructor

Description : Define pointer variable. Give its syntax.

Last Answer : Definition: Pointer is a variable that holds memory address of another variable of similar data type.  Syntax to declare pointer variable: data_type *pointer_variable;

Description : Define multiple inheritance. Give example.

Last Answer : Multiple Inheritance: When a single 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 from which it ... derived class derived from two base classes base class Test and base class Sports .  

Description : Define pointer. Give syntax for declaration of pointer. 

Last Answer : Definition: Pointer is a variable that holds memory address of another variable of similar data type.  Syntax to declare pointer variable: data_type *pointer_variable;

Description : Define pointer.

Last Answer : Pointer is a variable which holds an address of another variable of same data type.

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 : 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 using concept of pointers to string for performing following operations: (i) String concatenation (ii) String comparisons

Last Answer : (i) Program to implement String Concatenation: #include #include void main() { char s1[50],s2[30],*p,*q; clrscr(); couts1>>s2; p=s1; q=s2; while(*p!=NULL) { p++; } while(*q!=NULL) { *p=*q; p++; q++; } *p='\0'; cout