A. outer class.
B. local class.
C. global class.
D. super class.
A class is said to be a global class, if its definition occurs outside the bodies of all functions in a program.
A. local object.
B. global object
C. outer object.
D. inner object.
A local object can be accessed only within the function body and it cannot be used outside the function. A local object can be created from both types: local and global.
A. local object.
B. global object.
C. inner object.
D. outer object.
The global object is available to all the functions in the program, i.e., this object can be used anywhere in the program. A global object only is declared using a global class type.
A. nested class.
B. enclosing class.
C. nesting of member functions.
D. binding of member functions.
The public member functions of a class can be invoked only by using an object of that class using a dot operator. However, a member function of the same class can call another member function of the same class using its name. We do not need an object to call them. When a member function is called by another member function, it is known as nesting of member functions.
A. setters.
B. getters.
C. mutator functions.
D. manager functions.
Accessor functions are those member functions that allow us to access the data members of an object. However, accessor functions cannot/do not change the value of data members.
A. virtual class.
B. dependent class.
C. pure abstract class.
D. class.
Interface generally refers to an abstraction that an entity provides of itself to the outside. This separates the methods of external communication from internal operation and allows it to be internally modified without affecting the way outside entities interact with it, as well as provide multiple abstractions of itself.
A. global class.
B. local class.
C. friend class.
D. nested class.
A class is said to be global class if its definition occurs outside the bodies of all functions in a program, which means that object of this class type can be declared from anywhere in the program.
A. a constructor.
B. an attribute.
C. a constructor and an attribute.
D. an overloading.
A constructor is a special member function which will construct an object with user-defined values whenever object is created. It is a special method used in OOP, which puts the object member into a valid state.
A. aggregation.
B. abstraction.
C. modularity.
D. encapsulation.
Abstraction is focusing on the details of an object leaving behind the implementation details, which are not essential.
A. mutator functions.
B. accessor functions.
C. manager functions.
D. inline functions.
Manager functions are member functions with specific functions (e.g., constructors and destructors) that deal with initializing and destroying class instances.
A. polymorphism.
B. inheritance.
C. data abstraction.
D. encapsulation.
Inheritance is the property by which derived class inherits the characteristics and properties of the base class and thus reuse it.
A. self–referential structure.
B. structure.
C. base structure.
D. derived structure.
Self–referential structures are the structure containing a member that is a pointer to the same structure type. Self–referential structures are useful for forming lined data structures such as linked lists, stacks and trees.
A. abstract.
B. inline.
C. inlined.
D. inlining.
The inline functions are a C++ enhancement designed to speed up programs. The coding of the normal functions and inline functions is similar except that inline functions' definitions start with the keyword inline. An inline function definition should be placed above all the functions that call it.
A. it increases time as function is invoked again and again.
B. a fragmentation of code.
C. its memory is wasted.
D. it does not return any value.
Whenever the function is invoked the same function code is inserted in the program for every function call, so memory is wasted.
A. one.
B. two.
C. three.
D. four.
There are 3 access labels provided by the class: private, protected and public.
A. make programs slower.
B. code union.
C. insecurity of data.
D. encapsulation of data.
Inline functions improve performance by avoiding the overhead of the call itself but their overuse can lead to negative performance and make programs slower.
A. it is very big just like macros.
B. it is very small and does not return any value or contain any static variables.
C. it contains static variables and return a value.
D. it is a very big function and does not contain any static variables.
An inline function is a function whose code gets inserted into the caller’s stream code. The functions should be inlined only when they are small. There is no point inlining large functions as there would be heavy memory penalty.
A. only members outside the class.
B. only members of the class.
C. members of a program.
D. members of a package.
Any member having private keyword is accessible to members within the class.
A. member function.
B. data member.
C. object.
D. class.
There are two kinds of members in a class: data members and member functions. Data members are exactly like the variables in a structure and member functions act on data members in the class.
A. colon.
B. semicolon.
C. comma.
D. dot.
Member access specifiers like private, protected and public can appear any number of times in a class and they are always terminated with a colon (:).
A. will give an error in this case.
B. needs to be stored in another variable c4.
C. will return a value in another variable.
D. gets stored in c3 automatically.
There is no need to return a value, as the result gets stored in c3 when the function is called.
A. function overloading.
B. operator overloading.
C. virtual pointers.
D. polymorphism.
By overloading operators like +,*,-which are supposed to work on standard data types like ints, floats etc, they can work differently. Example, by overloading + operator it can be used to add two strings which is not possible in c.
A. function prototype only.
B. function definition.
C. function parameter.
D. function calling.
In C++, we have an option to define default values for arguments that are not passed when the function call is made. The compiler uses the prototype information to build a call, not the function definition.
A. nested class.
B. inner class.
C. disclosing class.
D. enclosing class.
A class may be declared within another class. A class declared within another class is called a nested class. The outer class is known as enclosing class and the inner class is known as nested class.
A. delete.
B. new.
C. malloc( ).
D. free( ).
The new operator, when used with the pointer to a data type, a structure, or an array, allocates memory for the item and assigns the address of that memory to the pointer.
A. constant member function.
B. manager function.
C. mutator function.
D. accessor function.
A constant member function is denoted using the keyword const. The qualifier const appears both in member function declarations and definitions. Once a member function declared as const, it cannot alter data values of the class.
A. by a object of another class.
B. using scope resolution operator by an object of different class.
C. using dot operator by an object of that class.
D. by constructor of that class.
Member function is always called to operate on the specific object, not on the class in general. It is accessed using dot operator, which is also known as “ class member access operator ”.
A. the data members in the class.
B. the data members outside the class.
C. the methods within the class.
D. the objects.
There are two kinds of members in a class: data members and member functions. Data members are exactly like the variables in a structure and member functions act on data members in the class.
A. data.
B. method.
C. variable.
D. scope resolution operator.
A class is a collection of data types and functions, which operate on them. The functions defined within a class, are known as member functions or methods.
A. setters.
B. getters.
C. manager functions.
D. accessor functions.
Mutator functions are also known as setters. these are the member functions that allow us to change the data members of an object.
A. data binding.
B. data hiding.
C. security.
D. polymorphism.
When we use private keyword it means that data is accessible within a class and it cannot be accessed outside the class. thus maintain data hiding.
A. colon.
B. comma.
C. semicolon.
D. colon.
The body of a class is delimited by braces and terminated by semicolon.
A. object creation.
B. object formation.
C. instantiation.
D. instant object.
An object is an instance of a class. It is the root of class hierarchy and the process of creating it is called instantiation.
Yes we can. Consider the structure definition below-
struct date{ int day;
int mon;
int year;
};
struct employee{
int ecode;
char ename[20] ;
char addr[30] ;
date dob;
};
The array of structures is declared as - employee E[10];
Simple members may accept data as - cin>>E[i].ecode;
Members of nested structure date can accept data as -
cin>>E[i].dob.day;
cin>>E[i].dob.mon;
cin>>E[i].dob.year;
where i is the array index.
An arrya is used to hold homogeneous data types. To store items of different data types we can use structures. A structure is a collection of variables under a single name. Varibales can be of any data type like int, float, char,etc.
Yes, we can group data of different types using structures. A structure is a collection of variables types grouped together. Structures are useful whenever a lot of data needs to be grouped together. For example, when dealing with the students in a college, many variables of different types are needed like name, address, age, grade, subject. All these are grouped under one entity, i.e. structure.
Structure date is a nested member of struct info, it should be defined before info.
|
NAME |
CLASS |
ROLLNO |
DATE_OF_BIRTH |
ADDRESS |
||
|
|
|
|
|
|
|
|
|
|
|
|
DAY |
HOUSE NO |
||
|
|
|
|
MONTH |
AREA |
||
|
|
|
|
YEAR |
CITY |
||
|
|
|
|
|
PINCODE |
||
struct date{ int day;
int mon;
int year;
} ;
struct addrs{ int houseno;
char area[20];
char city[15];
long pincode;
} ;
struct student{ char name[15];
char class[6];
int rollno;
date date_of_birth;
addrs address;
i) d1=d2; Correct – same data type
ii) D1=d2; Incorrect, D1 and d2 are different data types, DATE and date
iii) date d3={22,8,2005}; Correct, initialization possible
iv) date d4; d4={12,2,2005}; Incorrect, for a declared variable, assign values to members
v) DATE D={4,3,1999}; Correct
#include< iostream.h> #include< iostream.h>
#define area l*b #define square(a) a*a
void main(){ void main(){
int l,b; int a=5;
cout<<"enter length : "; cin>>l; cout<< square(a);
cout<<"nbreadth : "; cin>>b; }
cout<<"area = "<< area;
}
//using simple structures
#include < iostream.h>
#include < conio.h>
struct S{
char clas[6];
int rollno;
char name[20];
int eng;
int science;
int math;
int socsc;
};
void main(){
S s;
char c;
clrscr();
cout<<"Class and Section : ";cin.getline(s.clas,6);
cout<<"Roll number : ";cin>>s.rollno;
c=cin.get();
cout<<"nName : ";cin.getline(s.name,20);
cout<<"nEnglish marks : ";cin>>s.eng;
cout<<"nScience marks : ";cin>>s.science;
cout<<"nMath marks : ";cin>>s.math;
cout<<"nSoc.Science Marks : ";cin>>s.socsc;
cout<<"n Total = "<< s.eng+s.science+s.socsc+s.math;
getch();
//using simple structures
#include < iostream.h>
#include < conio.h>
struct S{
char clas[6];
int rollno;
char name[20];
int eng;
int science;
int math;
int socsc;
};
void main(){
S s;
char c;
clrscr();
cout<<"Class and Section : ";cin.getline(s.clas,6);
cout<<"Roll number : ";cin>>s.rollno;
c=cin.get();
cout<<"nName : ";cin.getline(s.name,20);
cout<<"nEnglish marks : ";cin>>s.eng;
cout<<"nScience marks : ";cin>>s.science;
cout<<"nMath marks : ";cin>>s.math;
cout<<"nSoc.Science Marks : ";cin>>s.socsc;
cout<<"n Total = "<< s.eng+s.science+s.socsc+s.math;
getch();
#include< iostream.h>
#include< conio.h>
struct Addr
{
int eno;
char name[20];
char address[20];
};
struct Employee
{
int sal;
char dept[20];
Addr ad;
};
void main()
{
Employee emp;
cout<< "nEnter EmpNo:";
cin>> emp.ad.eno;
cout<< "nEnter Name: ";
cin>> emp.ad.name;
cout<< "nEnter sal: ";
cin>> emp.sal;
cout<< "nEnter Dept: ";
cin>> emp.dept;
cout<<"nEnter Address: ";
cin>> emp.ad.address;
cout<< "nEmployee Record: ";
cout<< "Name:"<< emp.ad.name;
cout<< "nEmpNo: "<< emp.ad.eno;
cout<< "nSalary: "<< emp.sal;
cout<< "nDept: "<< emp.dept;
cout<< "nAddress: "<< emp.ad.address ;
}
//using array of structures
#include < iostream.h>
#include < conio.h>
struct date{
int dd;
int mm;
int yy;
};
struct S{
int admno;
char fname[10];
char lname[10];
long phone;
date dob;
};
void main(){
S s[35];
int i,adno;
char c;
clrscr();
for(i=0;i<35;i++)
{
clrscr();
cout<<"Admission Number : ";cin>>s[i].admno;
c=cin.get();
cout << c;
cout<<"nFirst Name : ";cin.getline(s[i].fname,10);
cout<<"nLast Name : ";cin.getline(s[i].lname,10);
cout<<"nContact telephone : ";cin>>s[i].phone;
cout<<"n date of birth - day :";
cin>>s[i].dob.dd;
cout<<"n month :";
cin>>s[i].dob.mm;
cout<<"n year :";
cin>>s[i].dob.yy;
getch();
}
clrscr();
cout<<"Enter Admission Number : "; cin>>adno;
for(i=0;i<35;i++)
{
if (adno= =s[i].admno)
{
cout<<"nName : "<< s[i].fname << ' '<< s[i].lname ;
cout<<"nContact Telephone : "<< s[i].phone;
cout<<"nDate of Birth = "<< s[i].dob.dd<< '-'<< s[i].dob.mm<< '-'<< s[i].dob.yy;
break;
}
}
getch();
}
//passing a date variable to a function by value
#include < iostream.h>
#include < conio.h>
struct date{ int day;
int mon;
int year;
};
void main()
{
date d;
int val;
clrscr();
int valid(date);
cout<<"nEnter date - day :";
cin>>d.day;
cout<<"n month :";
cin>>d.mon;
cout<<"n year :";
cin>>d.year;
val=valid(d);
if (val==1)
cout<< "nValid date";
else
cout<<"nInvalid date";
getch();
}
int valid(date dt){
int v; v=0;
int days[]={31,28,31,30,31,30,31,31,30,31,30,31};
if(dt.mon==2 && dt.day==29 && dt.year%4==0)
v=1;
else
if (dt.mon<1 || dt.mon>12)
v=0;
else
for(int i=0;i<12;i++){
if (dt.day<=days[dt.mon-1])
v=1;
break;
}
return v;
#include< iostream.h>
#include< conio.h>
struct Teacher
{
int id;
char name[20];
char quali[20];
char desig[20];
}t={111,"Soumya","MCA","TGT"};
void main()
{
cout<< "nTeachers Record: ";
cout<< "Name:"<< t.name;
cout<< "nId: "<< t.id;
cout<< "nQualification: "<< t.quali;
cout<< "nDesignation: "<< t.desig;
}
#include< iostream.h>
#include< conio.h>
struct Info
{
int rno;
char name[20];
};
struct Student
{
int clas;
int mks;
Info ob;
}s1={12,345};
void main()
{
cout<< "nEnter Name: ";
cin>>s1.ob.name;
cout<< "nEnter Rno: ";
cin>>s1.ob.rno;
cout<< "nStudent Record: ";
cout<< "Name:"<< s1.ob.name;
cout<< "nRollNo: "<< s1.ob.rno;
cout<< "nClass: "<< s1.clas;
cout<< "nMarks: "<< s1.mks;
}
//passing to a function by reference.
#include < iostream.h>
#include < conio.h>
struct ITEM
{
int icode;
char iname[20];
int unit_cost ;
int qty_in_stock;
};
void main()
{
ITEM I[10];
char c;
void update(ITEM&);
for(int i=0;i<10;i++)
{
clrscr();
cout << "Enter item code : ";
cin >> I[i].icode;
c = cin.get();
cout << "Enter item name : " << c;
cin.getline(I[i].iname,20);
cout<<"Enter unit cost : ";
cin >> I[i].unit_cost;
cout << "Enter quantity in stock :";
cin >> I[i].qty_in_stock;
}
for(i=0;i<10;i++)
{
if(I[i].qty_in_stock==0)
update(I[i]);
}
for(i=0;i<10;i++)
{
cout << "Code : " << I[i].icode;
cout << "Name : "<< I[i].iname;
cout << "Unit Cost : " << I[i].unit_cost;
cout << "Current Stock : " << I[i].qty_in_stock;
getch();
}
void update(ITEM &item)
{
item.qty_in_stock=100;
}
A. the declaration of static data member count of class s.
B. the definition of static data member count of class s, that initializes count with value 10.
C. both declaration and definition of static data member count of class s, assigning value 10 to count.
D. declaration of static data member count of class s, and giving default value 10 to count.
It is the definition of a static data member count of class s and data member count is given initial value 10 at the time of definition.
A. private.
B. public.
C. protect.
D. default.
Private members are the class members that are hidden from the outside world. The private members implement the OOP concept of data hiding.
A. no class declaration only.
B. no class declaration and no colon after public.
C. no class declaration and no semicolon after public.
D. no colon after public keyword only.
A class declaration having class keyword and class-name is must for every class. There should be colon after all the access specifiers i.e. public, private and protected.
A.
class-name :: class-member-name.
B. class-name : class-member-name.
C. :: class-name :: class-member-name.
D. :: class-name : class-member-name.
The scope resolution operator (::) is useful to distinguish between class member names and other names. For example,
class A
{
int x;
float y;
public:
void readm( ) const;
....
...
};
In this class the full qualified name of variable x is A::x.
A. friend.
B. inline.
C. virtual.
D. member function.
in inline function, at each place where there is a function call in the source file, the actual code from the function would be inserted, instead of a jump to the function.
It is less than the scope resolution operator ::, the parenthesis ( ) and array access [ ] operators.
Macros are also given as preprocessor directives i.e. # define is used to define macros too. Macros may be equivalent to expressions, complete statements or groups of statements. They resemble functions but are treated differently during compilation. A macro defined in one file is not recognized in another file. Macro definitions are customarily placed at the beginning of the file.
The entire structure can be passed to the functions in two ways : by value and by reference. Passing by value is useful when the original values are not to be changed and passing by reference is useful when original values are to be changed.
Structure assignment is possible only if both the structures are of same structure type. Only assignment (=) is possible for two similar structures. Other operations, such as comparisons (== and !=) are not defined for similar structures.
The structure variable name followed by a period (.) and the element name reference to that individual structure element. The syntax for accessing a structure element is :
structure-name.element-name
In C++, a structure is a class declared with keyword struct and by default, all members are public in a structure.
struct Salesman
{
int id;
float salary;
int totalsales;
};
Structures are useful when a lot of data needs to be grouped together. Once defined, the structure name becomes a user defined data type and may be used the same way as other built-in data types.
struct student
{ int rollno;
char name[20];
float marks[3];
};
student result[3]
{ {01,"Reena", {82.0,91.5,78.0} }, //structure 0
{02,"Aakash", {68.0,71.0,57.0} }, // structure 1
{03,"Venkat", {61.0,59.0,70.0} }, // structure 2
};
The structure is a user defined data type that acts as a template for creating variables of that type.
For Example –
struct date{ int day;
int mon;
int year;
};
A self referential structure has an element that refers to the structure itself. This is actually a pointer that points to a structure of the same type.
For Example –
struct date{ int day;
int mon;
int year;
date *dt;
Yes we can. Consider the structure definition below-
struct date{ int day;
int mon;
int year;
};
struct employee{
int ecode;
char ename[20] ;
char addr[30] ;
date dob;
};
The array of structures is declared as - employee E[10];
Simple members may accept data as - cin>>E[i].ecode;
Members of nested structure date can accept data as -
cin>>E[i].dob.day;
cin>>E[i].dob.mon;
cin>>E[i].dob.year;
where i is the array index.
A class is declared using the keyword class while a structure needs the keyword struct. All members are private by default in a class while in a structure they are public. Traditionally, structures are used to declare data only while classes have both data and functions.
Array elements are all of the same data type while in a structure they may not be. In an array, individual elements are accessed using the index number (or subscript) while in a structure, a dot is used to access members.
Preprocessor commands are called DIRECTIVES and begin with a pound / hash symbol(#). No white space should appear before the # and a semi colon is NOT required at the end.
# define and #include are two commonly used preprocessor directives.
#include< iostream.h > - this is an instruction to include the file iostream.h
#define PI 3.14 - this defines a symbolic constant PI and replaces every PI in the program with 3.14
typedef is a keyword used to give an alternative name to an existing data type. Once a structure has been declared, typedef can be used to give it an alias. Then onwards, both the names for the data type can be used.
Example -
typedef long telephone; // telephone can also be used to declare variables of long type
telephone office, residence;
long neighbour;
typedef float money; // float and money both can be used to declare float variables
float amount;
It is incremented by the size of the structure.
struct Customer
{
int custnum;
int salary:
float commission:
};
A self referential structure is used to create data structures like linked list, stacks, etc. It has an element that refers to the structure itself. This is actually a pointer that points to a structure of the same type.
For Example –
struct node
{
int data;
node*next;
}
The structures are defined globally so that variables of this structure type can be declared in any function. A structured declared within a function is available only to that function.
A. polymorphism.
B. encapsulation.
C. abstraction.
D. inheritance.
Simplified view of object that includes only features in which one is interested in and hides unnecessary details is known as data abstraction. For example, while driving a car, we are not concerned about the hidden parts such as fuel injection, disk brake etc.
A. constant member function.
B. scope resolution operator.
C. inline function.
D. nesting of member function.
Inline functions speed up the program. The only difference between inline functions and the normal functions is that inline functions' definitions start with the keyword inline.
A. accessor function.
B. mutator function.
C. manager function.
D. constant member function.
Accessor member functions allow us to access field of object but cannot change the value of data members. For example, getRollno( ) and getMarks( ) which can read the roll number and marks of a student, respectively.
A. it saves time.
B. it doesn't produce compile time error.
C. it reduces size of the program.
D. data is edited in desired manner.
By providing accessors and mutators, we make sure that data is edited in desired manner through a mutator. Further, if a user wants to know current value of a private data member, s(he) can get it through an accessor function. Accessor and mutators are also called getters and setters.
A. member functions.
B. nesting of member functions.
C. calling of member functions.
D. inlining of member functions.
The public members of a class can be invoked only by using an object of that class using a dot operator. However, a member function of the same class can call another member function of the same class using its name. We do not need an object to call them. It is known as nesting of member functions.
A. a and b.
B. only a.
C. add( ) and print( )
D. a, b and c
The private members can be accessed only from within the class. A class specification involves the declarations of its data member and member functions. There are two ways to layout a class definition. The first way is to place the private data before the public functions and data. The second way is to place the public members first, followed by protected and private members.
A. 9 – no objects declared for class B in class A
B. 3 - class B declared under private
C. 12 – a1 shows no reference to B
D. 14, 15 - B is declared under private in the class A, so, cannot be accessed.
The private data members can be accessed only from the member functions of the class.
A. nested class
B. polymorphism
C. containership
D. inline object
A class declared within another class is called as nested class. The outer class is known as enclosing class and the inner class is known as nested class.
A. using a member function.
B. using a dollar sign.
C. using an object only.
D. using the name of the enclosing class.
The nested class can access public members of its enclosing class using an object only.The same applies for enclosing class also i.e., it can access public members of nested class through an object.
A. manager functions.
B. mutator functions.
C. accessor functions.
D. inline functions.
Manager functions are member functions with specific functionality (e.g., constructors and destructors) that deal with initializing and destroying class instances.
A. Incorrect header file included.
B. cin >> a >> b;
C. int sum(int a, int b){return (a+b)}
D. cout << s;
The sum function should be so defined to calculate and return the summation result of the given values to the calling function. Therefore, the sum function should be corrected as:
#include< iostream.h >
void main()
{
int a, b;
cin >> a >> b;
int s = sum(a, b);
cout << s;
}
int sum(int a, int b)
{
return (a+b);
}
A. encapsulation.
B. nesting.
C. polymorphism.
D. abstraction.
One class may have another class defined within it, known as nested class. One way of doing so is that a class contain objects of other classes as its members as shown below:
class X
{
...
...
}
class Y
{
...
...
}
class Z
{
X O1;
Y O2;
...
};
A. declaration of variables cannot be done without access specifier
B. a function cannot have void as parameter
C. cannot use static modifier with datatypes
D. a static member function is accessing a non-static member
The static member functions are the functions that can access only the static members. So, in the above code fragment a static member function is trying to access a nonstatic member which is the error.
To correct it the static member function should be as given below :
static void prn(void)
{
cout << ctr;
}
A. string.h
B. conio.h
C. math.h
D. ctype.h
math.h is a header file in the standard library of the C++ programming language designed for basic mathematical operations.
A. polymorphism.
B. data hiding.
C. inheritance.
D. nesting.
In the given code, only the public members are accessible by outside of the class. Data Hiding term is used so that only relevant information is exposed to the user and rest of the information remains hidden from the user. The class groups its members (data and functions) into three sections : private, protected and public, where private and protected members remains hidden from outside world and thereby support data hiding.
A. global class type.
B. private class type.
C. local class type.
D. nested class type.
A class is said to be global class if its definition occurs outside the bodies of all functions in a program, which means that object of this class type can be declared from anywhere in the program, An object is said to be a global object if its declared outside all the function bodies and it means that this object is globally available to all functions in the program i.e., this object can be used anywhere in the program.
A. static int X::Count:
B. int X::Count;
C. X::int count;
D. X::static count;
A static data member of a class is just like a global variable for its class. Two things are needed for making a data member static:
1. declaration within the class definition.
2. definition outside the class definition.
The declaration of a static data member within the class defintion will look like :
class X
{
static int count ;
...
};
The definition of above declared static member count outside the class will be as follows:
int X :: count;
Therefore, the entire class definition would look like as:
class X
{
static int count;
...
};
int X :: count;
A. so that they can access global variables.
B. so that they can call private members.
C. so that they can be easily modified.
D. so that they can be called from outside functions.
Member functions are set of operations that may be applied to objects of that class. The public members can be accessed from outside the class also therefore, it is preferred to define the member functions as public.
A. only local class type.
B. only global class type.
C. both local and global class type.
D. only static class type.
An object is said to be a local object if it is declared within a function, which means that this object is locally available to the function that declares it and cannot be used outside the function declaring it.
A. inheritance.
B. polymorphism.
C. encapsulation.
D. modularity.
When a class is inherited all the functions and data member are inherited, although not all of them will be accessible by the member functions of the derived class. Similarly, a child inherits properties from both the parents.
A. data.
B. functions.
C. private.
D. public.
By default, all the members are public in a structure but private in a class. In a class, the data members are declared similar to the other variable declarations in C++ and the member functions are declared by providing their prototypes.
A. independent of the object being used for referencing them.
B. dependent upon the object being used for referencing them.
C. not defined.
D. always fixed as global scope.
If the referencing object is a global object, then the scope of public members is also global, whereas if the referencing object is a local object, then the scope of public members is also local.
A. only by public member functions.
B. only by the object.
C. by using the class name and scope resolution operator.
D. by other member functions of the same class.
Private members implement the concept of data hiding.They can be accessed only by member functions of the class in which they are declared.
A. can be inherited.
B. cannot be accessed by member functions of the same class.
C. can be accessed by non-members functions.
D. cannot be inherited.
Protected members can be used only by member functions and friends of the class in which it is declared.
A. the class must be global
B. function main( ) must be using it
C. the class must be defined in main ( )
D. it must be returned from a function
An object is said to be global object if it is declared outside all the function bodies.
A. so that they can access global variables
B. so that they can call private members
C. so that they cannot be called from outside functions
D. so that they can be called from outside functions
There are three access specifiers: public, private and protected. Public members can be accessed by outside member functions also, whereas private members can be accessed by member functions within the class only. Member functions are generally defined as public so that they can be called from outside functions.
A. keyword Class, followed by class-name, followed by members within braces
B. keyword Class, followed by private members and functions, within braces
C. keyword Class, followed by data members and functions within braces
D. keyword class, followed by class-name, followed by members within braces