List various visibility modes used in inheritance.

1 Answer

Answer :

Different visibility modes used in inheritance are:

1) Private

2) Protected

3) Public 

Related questions

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 different visibility modes and its effect in inheritance.

Last Answer : Different visibility modes are: 1) Private 2) Protected 3) Public Effect in inheritance: Private members of base class are not inherited directly in any ... become protected members of derived class and public members of base class become public members of derived class

Description : State and describe visibility modes used in inheritance with their effects.

Last Answer : Visibility modes: private protected public Private: o When a base class is privately inherited by a derived class, public members and protected members of the base class become ... class Syntax: class derived: protected base { //Members of derived class; };

Description : List different types of inheritance with suitable diagram.

Last Answer : Types of inheritance: 1) Single inheritance: A derived class is derived from only one base class. Diagram: 2) Multiple inheritance: A derived class is derived from more ... ) Hybrid inheritance: Combination of single, multiple, multilevel and hierarchical inheritance.  Diagram:

Description : State and describe visibility modes and its effects used in inheritance.

Last Answer : Different visibility modes are: 1. Private 2. Protected 3. Public Effects of visibility modes in inheritance:  Private members of base class are not inherited directly in any ... members of derived class and public members of base class become public members of derived class.

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 : Write a program for multiple inheritance. 

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

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 : 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 hybrid inheritance with example.

Last Answer : Hybrid inheritance is also referred as mixed inheritances. As the name suggests it is a combination of all the kinds of inheritance mechanisms, namely single inheritance, multiple inheritance, multilevel inheritance and hierarchical inheritance. ... { D d; d.getdata(); d.putdata(); }  

Description : Implement single inheritance for following fig. Accept and display data for 1 table.

Last Answer : #include class furniture { protected: char material[20]; int price; }; class table :public furniture { int height ; float sur_area; public: void getdata() { coutmaterial; coutprice; coutheight; coutsur_area; } void putdata() { cout

Description : Write any two advantages of inheritance.

Last Answer : Advantages of inheritance: 1) Use of inheritance in a program gives reusability of code. 2) Inheritance avoids duplication of code in program. 3) Inheritance reduces length of code. 4) Inheritance reduces time to compile the lengthy code by reusing it. 

Description : Explain single inheritance with suitable example.

Last Answer : When a single derived class is derived from only one base class then it is called as single inheritance. In a single inheritance, derived class can inherit some or all members of base class. It is implemented by specifying ... s; clrscr(); s.getdata(); s.putdata(); getch(); }

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 : Write a program in C++ to implement single inheritance from following figure:

Last Answer : #include<iostream.h> #include<conio.h> class product { protected: int prodid; char prodname[20]; }; class edible:public product { char flavour[20]; public: void accept() { cout<< ... for(i=0;i<5;i++) { e[i].display(); } getch(); }

Description : With example, describe multiple inheritance. 

Last Answer : A derived class with multiple base classes is called as multiple inheritance. A derived class inherits properties of all the base classes. It also can have its own properties. Syntax:- class base _class _name1 { ____ } ... clrscr(); derived d; d.get2(); d.put2(); getch(); }

Description : Write a program in C++ to implement following inheritance. Assume suitable data.

Last Answer : #include<iostream.h> #include<conio.h> class employee { int empid; char empname[20]; public: void accept() { cout<<"\n enter empid, empname:"<<endl; cin>>empid>> ... m.acc1(); m.dis1(); w.acc2(); w.dis2(); getch(); }

Description : State and describe types of inheritance.

Last Answer : Types of inheritance: o Single Inheritance o Multiple Inheritance o Multilevel Inheritance. o Hierarchical Inheritance o Hybrid Inheritance Single Inheritance o The mechanism of deriving a new class from existing single ... : public B, public C { // class D body; };

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 : List characteristics of static data member and static member function.

Last Answer : Characteristics of static member variable are: i) It is initialized to zero when the first object of its class is created. No other initialization is permitted. ii) Only one copy of that ... the class name with a scope resolution operator instead of object name as follows: class_name::function_name;

Description : List any six characteristics of OOP. Also list any two OOP languages.

Last Answer : Characteristics of OOP: 1) Emphasis is on data rather than procedure. 2) Programs are divided into objects. 3) Data structures are designed such that they characterize the objects. 4) Functions that operate on the data of ... 4) C++ 5) Ada 6) Object Pascal 7) Turbo Pascal 8) Eiffel 9) Java

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 : 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 : 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 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 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 : 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 : 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