A. base class.
B. concrete class.
C. abstract class.
D. super class.
An abstract class is meant to be used as a base class from which other classes are derived.
A. Abstraction.
B. Inheritance.
C. Encapsulation.
D. Modularity.
Abstraction is the process by which data and programs are defined with a representation similar to its meaning (semantics), while hiding away the implementation details. Abstraction tries to reduce and factor out details so that the programmer can focus on a few concepts at a time.
A. data abstraction.
B. encapsulation.
C. data hiding.
D. inheritance.
Data abstraction is focusing on the important features leaving behind the unessential part.
A. data abstraction.
B. encapsulation.
C. data hiding.
D. inheritance.
Data hiding is a related concept to data abstraction.
A. data abstraction.
B. data hiding.
C. data encapsulation.
D. modularity.
Through encapsulation, an inteface is made available to the world through which users can use the class.
A. the best programming method.
B. a programming method that localizes the implementation details.
C. a programming method, which implements oops concepts.
D. a programming method, which leads to increased time and cost overheads during design changes.
Procedural programming is susceptible to design changes, which leads to many modifications in the code. This results in increased time and cost overheads at times.
A. programming paradigm.
B. programming procedure.
C. programming function.
D. programming class.
Paradigm refers to a way of doing things. A programming paradigm gives you an idea how problems are generally analyzed and solved in a particular programming language.
A. protected data.
B. private data.
C. public data.
D. local data.
Public data is accessible even outside the class.
A. public data.
B. private data.
C. either public or private data.
D. protected data.
Private data is accessible within a class only.
A. similar objects.
B. different types of objects.
C. different entities.
D. same variables and different data types.
A class is a way to bind the data describing an entity and its associated functions together.
A. the data members of 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 of the class.
A. data.
B. method.
C. variable.
D. scope resolution operator.
A class is a collection of data members and member functions, which operate on them. The functions defined within a class, is called as member functions or methods.
A. public and private.
B. public.
C. private.
D. private and public.
The data within a class is private, i.e., the data is hidden so that it will be safe from accidental manipulation. The functions are public so that they can be accessed from outside the class.
A. late binding or virtual binding.
B. static binding.
C. early binding.
D. compile time binding.
Name binding is an association of values with identifiers. The binding performed as the program runs is called dynamic binding or late or virtual binding.
A. The ability to perform according to the situation.
B. The ability to acquire features of another class.
C. The wrapping up of data and associated functions into a unit.
D. Protecting data from access by any function.
Inheritance is a way to form new classes (instances of which are called objects) using classes that have already been defined. Inheritance is intended to reuse existing code with little or no modification. The new classes, known as derived classes, inherit attributes and behavior of the pre-existing classes, which are referred to as base classes (or ancestor classes).
A. Ability to be in different forms.
B. Representing essential features.
C. Binding data and functions together.
D. Process of argument matching.
Data encapsulation is the wrapping up of data within a classes, enhancing information hiding features.
A. Ability to be in different forms
B. Representing essential features
C. Making data inaccessible to outside functions
D. Ability to take on features of another class
Data hiding is a characteristic of object-oriented programming in which an object can only be associated with data in predefined classes or templates.
A. Representing essential features
B. Bundling data and functions together
C. An entity with some properties
D. Ability to be in different forms
Data abstraction is the process of representing essential features without including implementation details.
A. object Based programming
B. object Oriented programming
C. procedural programming
D. advanced programming
In Procedural programming, programs are written as a list of instructions in a sequence.
A. reusability of class.
B. renaming of class.
C. decomposing of class.
D. encapsulation of hierarchy.
In object-oriented programming, inheritance is a way to form new classes (instances of which are called objects) using classes that have already been defined.
A. classes
B. functions
C. modules
D. program
To implement all OOP features in C++, like Encapsulation, data abstraction and data hiding we need to use classes.
A. Data hiding, Encapsulation, Maintenance
B. Function signature, Encapsulation, Abstraction
C. Data hiding, Procedural Paradigm, Abstraction
D. Data hiding, Encapsulation, Abstraction
Data hiding is a characteristic of object-oriented programming in which an object can only be associated with data in predefined classes or templates. The object can only "know" about the data it needs to know about. Encapsulation is the inclusion of one thing within another thing so that the included thing is not apparent. Abstraction is the process or result of generalization by reducing the information content of a concept or an observable phenomenon, typically to retain only information which is relevant for a particular purpose.
A. gives the list of arguments with type.
B. gives the list of arguments with function's return type.
C. gives different definitions of the function.
D. gives the different names of the same function.
The function signature defines the set of traits associated with the activation of a function object.
A. abstraction.
B. polymorphism.
C. encapsulation.
D. concoction.
Function overloading (also polymorphism or method overloading) is a programming concept that allows programmer to define two or more functions with the same name, having different arguments.
A. can have any number of objects.
B. cannot have objects.
C. generally behaves as a base class.
D. can have neither data nor functions.
The derived class is expected to provide implementations for the member functions that are not implemented in the base class. A derived class that implements all the missing functionality is called a concrete class .
A. can have only one object.
B. can have neither data nor functions.
C. cannot access member functions.
D. does not generally have objects declared.
An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed.
A. to link objects to data.
B. at compile time.
C. at run time.
D. to bind data to functions.
Late binding is done at run time, to link function call with the code to execute.
A. to link objects to data
B. at compile time
C. at run time
D. to bind data to functions
Early binding - Assigning values to variables during design time or exposing object model at design time.
A. disambiguation.
B. static-linking.
C. function overloading.
D. function's signature.
Static binding is the selection of a particular call at the compile-time.
A. late binding.
B. static binding.
C. dynamic binding.
D. run time binding.
Name binding is an association of values with identifiers. The binding of names before the program runs is called static binding.
int Calcvol( int s); // for a cube s*s*s
int Calcvol( float l, int s); // for cuboid l*s*s
b. void XYZ(int a, float b, char c ), as the arguments list matches.
int calcint( int);
A. different data type.
B. int data type.
C. same data type.
D. char data type.
Arrays hold a fixed number of equally-sized data elements, which are of same data type.
A. protected.
B. public.
C. private.
D. restricted.
All structure members are public by default; class variables and constants are private by default, while other class members are public by default.
A. one.
B. two.
C. several.
D. limitless.
A structure tag name can be used to declare variable of a structure type.
A. line operator.
B. this operator.
C. arrow operator.
D. bow operator.
The -> (arrow) operator is used to access class, structure or union members using a pointer. A postfix expression, followed by an -> (arrow) operator, followed by a possibly qualified identifier or a pseudo-destructor name, designates a member of the object to which the pointer points.
A. create a new user defined structure.
B. define new data type names.
C. create an alias for an existing data type.
D. create new variables for an existing data type.
Every variable has a data type. typedef is used to define new data type names to make a program more readable to the programmer.
A. copy structure.
B. nested structure.
C. typedef structure.
D. UDT structure.
Nested structure enables us to nest one structure definition within another.
A. enclosed structure
B. contained structure
C. nested structure
D. doubled structure
A structure can contain other structure as member.
A. #define.
B. *define.
C. &define.
D. $define.
The #define directive can be used to either define a constant number or function or to replace an instruction in the code.
A. enum.
B. macro.
C. #define.
D. typedef.
The typedef does not actually create a new data class, rather it defines a new name for an existing type. This can increase the portability of a program as only the typedef statements would have to be changed. The syntax of typedef statement is : typedef type name;
A. with any data type.
B. only with fundamental data types.
C. only with user defined data types.
D. only with float data type.
Every variable has a data type. The keyword typedef is used to define new data type names to make a program more readable to the programmer.
A. structure variable will be passed by reference, the array by value.
B. structure variable and the array will be passed by reference.
C. structure variable will be passed by value and the array by reference.
D. structure variable and the array will be passed by value.
Pass by reference refers to a method of passing the address of an argument in the calling function to a corresponding parameter in the called function.
A. any change made is only temporary.
B. changes are made in the original values of the variable.
C. reference to the entire structure can't be passed.
D. changes cannot be made when reference to a structure is passed.
Two ways to pass arguments to a function are: pass by value and pass by reference. With pass-by-reference, the caller gives the called function the ability to access the caller's data directly and to modify that data if the called function chooses to do so.
A. tree elements.
B. graph elements.
C. character elements.
D. structure elements.
The . (dot) operator is used to access class, structure, or union members. The member is specified by a postfix expression, followed by a . (dot) operator, followed by a possibly qualified identifier or a pseudo-destructor name. The postfix expression must be an object of type class, struct or union. The name must be a member of that object.
A. there is an array of structure.
B. there is a nested structure with an array.
C. there is an array of nested structure.
D. the nested structure has an array.
The members of stuctures are accessed using dot operator. For example: To access the city member of address structure which is an element of another structure worker, we shall write: worker.address.city
A. pointer declared with keyword struct.
B. variable declared with keyword struct.
C. class declased with keyword struct.
D. function declared with keyword struct.
Structure is actually a class (in C++) declared with keyword struct. By default, all members are public in a structure, on the other hand, all members are private by default in classes.
A. class.
B. pointer.
C. structure.
D. data verification.
Arrays bring together a group of items of the same data type whereas structures bring together a group of related data items of any data type.
A. both are of the same type.
B. both have members of the same type.
C. tag was omitted while defining the structure.
D. both are of different types.
Copy structure can also be assigned to another structure only if both the structures are of same type.
A. Universal Demand Transmission.
B. User Defined Target.
C. User Defined Data Types.
D. Universal Defined Types.
User defined data types are created with the help of struct or class keywords.
A. pass a reference to it.
B. pass its address using a pointer variable.
C. pass it as a structure variable.
D. pass it as an array.
When we pass a structure as an argument, remember that the argument and the parameter are not the same variable. Instead, there are two variables (one in the caller and one in the callee) that have the same value, at least initially.
A. it nests one structure definition within another.
B. it returns structures or its reference.
C. it defines new data type.
D. both the structures are of same type.
A copy constructor is a special constructor in the C++ programming language used to create a new object as a copy of an existing object. The first argument of such a constructor is a reference to an object of the same type as is being constructed, which might be followed by parameters of any type.
When an operator displays different behaviour in different situations, it is called operator overloading. For example, ‘+’ is used to add numbers but it can be ‘overloaded’ to add two structure variables or class objects.
Polymorphism is implemented through Operator Overloading , Function Overloading and Virtual Functions.
An object is a basic entity in an Object Oriented System. It may represent a person, a publication, a place or any item for which the program may handle data. It is also defined as an instance of a class.
Larger and more complex programs are very difficult to maintain.
Emphasis is on procedure rather than data.
The way data is stored is critical and if the arrangement of data is changed, all functions that access it have to be changed.
A procedural program is written as a list of instructions, telling the computer, step-by-step, what to do: accept price, write in file, display item code, name, price, profit etc.
Paradigm refers to a way of doing something.
Programming paradigm refers to an approach to or style of programming.
When the selection of the appropriate function is done dynamically at run time. This is generally when virtual functions are in use.
When the compiler is able to select the appropriate function at compile time, based on a function call, it is called early or static binding. This is generally when overloaded functions are in use.
(a) An abstract class is used as a base class from which other classes are derived. No objects are declared for this class.
(b) A concrete class is derived from an abstract class and generally has object declared.
A function call first matches the number of arguments and the type of arguments and then calls the appropriate function.
1. The compiler first tries to find an exact match, where the number and types of actual and formal arguments are the same.
2. If there is no exact match, the compiler uses integral promotion to find a match for example, char can easily be converted to int.
3. If the above two does not work, then the compiler tries the built-in conversions to the actual parameters and then uses the function which matches. At times, there are multiple matches, and an error is generated.
The functions signature is its argument list. It includes the number and type of arguments.
Consider two functions – void fadd(int a, int b); and int fadd(int x, int y);
When the same function name has different definitions, it is known as function overloading. The definitions differ in the number and types of the arguments.
We must note that –
(i) The overloaded functions must have different arguments lists.
(ii) Overloading functions with the same argument list but different return type is not allowed.
(iii) Member functions cannot be overloaded by making one static and the other not, arguments being the same.
Advantages are –
(i) Reusability of code through classes and inheritance.
(ii) Data hiding helps to build secure programs.
(iii) Classes can be designed to represent real world entities, along with data and behaviour.
(iv) The data centered design lets us collect data in a more implementable form.
(v) Multiple object co-exist without any interference.
Object Based Programming bundles data and the functions that access it into a single unit, called class. Features include encapsulation, data hiding and abstraction.
Object Oriented Programming too bundles data and the functions that access it into a single unit, called class. Some important features are encapsulation, data hiding, abstraction, inheritance and polymorphism.
Some concepts used extensively in Object Oriented Programming are –
(i) Data abstraction
(ii) Encapsulation
(iii) Data hiding
(iv) Inheritance
A class binds together data and functions that access it, thus enforcing encapsulation.
The class represents essential features of the object, thus enforcing data abstraction.
a) Encapsulation - wrapping up of data and functions into a single unit is known as encapsulation.
b) Data hiding - insulation of data from direct access by the program is known as data hiding.
c) Abstraction - the inclusion of essential features, ignoring background details is known as abstraction.
d) Inheritance - the process by which objects of one class acquire the properties of the objects of another class is known as inheritance.
e) Polymorphism - the ability to exhibit different behaviour in different situations is known as polymorphism.
A. variable.
B. symbolic constant.
C. structure constant.
D. element.
Symbolic constant is a constant (value that does not change) with a name.
A. struct st{ int i; };
B. struct st{ };
C. struct st{}
D. struct st{int};
A structure is defined with the following syntax:
struct struct_name
{
A. it reserves memory space for the components.
B. it just defines the data.
C. it defines and provides a memory space to structure and not its components.
D. the compiler stores the components.
At this point of time, just the structure is being defined. Memory space is reserved when its variable is declared.
A. 10021001
B. 10021100
C. 10011002
D. 20010012
cout will display the values of a and b, which are the members of function struct. These members are called with the help of dot operator.
A. items of the same data type.
B. related data items.
C. integers with user defined names.
D. variables.
A structure is a collection of variables referenced under one name. It is a utility to access two or more interrelated variables.
A. struct foo;.
B. foo var;.
C. foo;.
D. int foo;.
A structure is declared using the struct keyword, followed by its name.
A.
call by value.
B. call by reference.
C. call by behaviour.
D. call by context.
When a function is passed by reference the called function declares a reference for the passed structure and refers to the original structure elements through its reference.
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.
An array wherever being declared, should contain elements of the same data type.
A.
It does not create a new data type.
B.
It creates just an alias for an existing data type.
C. An alias type name is defined for a standard data type.
D. It creates a new data type.
A typedef creates a new name to the existing datatype.
A.
addr stu_addr[50];
B.
addr stu_addr{50};
C. addr stu_addr50;
D. addr stu_addr(50);
This statement would create 50 sets of variables. To declare an array of structures, you must define a structure and then declare an array variable of that type.
A. the members are being passed by reference.
B. the first one is being passed by value and the other by reference.
C. the members are being passed by value.
D. the members are passed by structure.
Both are being passed by value since, no reference variable is being used.
A. structure member is being passed by value.
B. structure member is being passed by reference.
C. structure member will not be passed at all.
D. structure member will lose its value.
Here, the structure variable is being passed by value. As a result, there wouldn’t be any change in the values of the structure variable.
A. C.c;.
B. C.cc.c;.
C. cc.c;.
D. C.cc;.
Since c is a member of variable cc therefore, cc.c is used to access it.
A. it is an array of structure.
B. it is a nested structure with an array.
C. it is an array of nested structure.
D. it is a nested structure that has an array.
EMP[45] is an array of a structure salary nested inside a structure tax.
A. link file.
B. execution file.
C. preprocessor directive.
D. batch file.
A # sign in the beginning of a statement means, it is a preprocessor directive, i.e., the instructions given here will be processed before the program is compiled.
A. referencing structures.
B. complex structures.
C. recursive structures.
D. looping structures.
A structure inside another structure is called nested structure.
A. structure variable will be passed by reference and the array by value.
B. structure variable and the array will be passed by reference.
C. structure variable will be passed by value and the array by reference.
D. structure variable and the array will be passed by value.
For ABC, a reference variable is being used while for char, it is being passed by value.
A. money membership;
B. float charges;
C. typedef salary amount;
D. typedef money fees;
The statement "typedef salary amount" cannot run successfully because salary is not a fundamental or basic data type.
A. macro replaces a value in the code while const will declare a variable.
B. macro replaces after compilation while const is done during compilation.
C. macro substitution may affect size of the EXE file but, not the stack.
D. cost substitution may affect size of the EXE file but, not the stack.
Macros always replace the value of a variable before compilation while const acts like a simple constant during the compilation.
A. a structure inside a structure.
B. a structure that calls itself.
C. a pointer referencing to itself.
D. a pointer inside a structure.
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.
A. tag.
B. variable.
C. member name.
D. ;
Tag is the name of the structure, which is being declared.
A. functions only.
B. data and functions.
C. data and functions prototype.
D. data only.
In C++, a structure can contain only data. Here, we cannot declare functions inside a structure.
A. homogeneous data structure.
B. heterogeneous data structure.
C. homogeneous data type.
D. heterogeneous data type.
A structure is a heterogeneous data structure since, it stores different types of data.
A. structure.
B. struct.
C. define.
D. tag.
The format for a structure declaration is: struct tag { structure members; } variable names; where tag is a user selected name, structure members are data members accessed by variables declared as this structure type and variable names are the names of the variable declared as this type of structure.
struct time{ int hour;
int min;
int sec;
Structures can be passed by reference just as other simple types. When a structure is passed by reference the called function declares a reference for the passed structure and refers to the original structure elements through its reference. Thus, the called function works with the original values.
date D, *DT;
struct emp
{
int id;
char name;
char desg;
float salary;
} senior_employee, assistant_employee;
The above code fragment will produce an error because s1 and s2, though have similar elements but are of different types A and B respectively and hence they cannot be assigned to one another.