The output is 4,4.
The output is 5,7,6,8.
The output is
The correct program is
# include < iostream.h> //Correction 1
void main()
{
int x,y; cin>>x;
for(x = 0; x<5; ++x) //Correction 2
cout << y;
cout< < x << y; //Correction 3
}
Correction 1: The condition is terminated by a comma(,), instead of a
semicolon(;).
Correction 2: ‘<<’ is missing.
Correction 3: else cannot exist without if.
(i) printchar()
(ii) printchar(‘*’, 20)
(iii) printchar(‘=’,40)
(iv) printchar(‘*’, 30)
The problem in the code is that a function large() is being called by reference and constants are being sent as argument. When a function is invoked by reference only variables can be passed and not the constants and expressions.
Thus, to correct the above problem the calling function main() needs to be changed as follows:
..
..
void main()
{
int x = 10;
int y = 12;
}
..
.. // rest of the code remains the same
The output of the above program is 410.
(i) The while loop will run for two times.
(ii) The last value to be displayed is 13.
//Function to find the sum of series 1+2+3+…………..+N
int sumseries(int N)
{
int i, sum = 0;
for( i = 0; i< = N; i++)
sum = sum + i;
return(sum);
}
//Function to convert the inch to feet
void feet_inch(int inch)
{
float feet;
feet = float(inch)/12; // Typecasting
cout << “The person’s height in inch is “ << inch << endl;
cout<< “ The person’s height in feet is” << feet;
}
. //Function to swap A and B without using a third variable
void SWAP(int A, int B)
{
A = A + B
B = A - B;
A = A – B;
cout << “ntAfter swapping the value of A is ->” << A;
cout << “ntAfter swapping value of B is ->” << B;
getch();
}
A. derived class function would be called.
B. base class function would be called.
C. parent class would be called.
D. global class function would be called.
A virtual function is one whose behaviour can be overriden within an inheriting class by a function with the same signature.
A. by searching for exact match, a match through promotion, a match through standard conversion, a match through user defined conversion.
B. by searching for a match through promotion, a match through standard conversion, a match through user defined conversion.
C. by searching for exact match, a match through standard conversion, a match through user defined conversion.
D. by searching for exact match,then a match through promotion.
The sequence is by searching for exact match, a match through promotion, a match through standard conversion, a match through user defined conversion. A call to an overloaded function is resolved to a particular instance of the function through argument matching.
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
A derived class that implements all the missing functionality is called a concrete class . We can create object for concrete classes.
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
In C++ an abstract class is one which defines an interface, but does not necessarily provide implementations for all its member functions. An abstract class is meant to be used as the base class from which other classes are derived.
A. Reusability of class
B. Renaming of class
C. Decomposing of class
D. Encapsulation of hierarchy
C++ enhances the feature of reusability through Inheritance.
A. Function signature does not include list of arguments
B. Function signature does not include function name
C. Function signature does not include return type and function name
D. Function signature does not include data types of arguments
Signature of a function include name of the function with its argument numbers and types.
A. Dynamic binding
B. Static Binding
C. Object Binding
D. Data Binding
Dynamic binding, because it happens at run time
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 concept in C++. In C Language Struct can not hide data of its data members. Where as in C++, we got the luxary of hiding data using e different access levels - private, protected, public
Encapsulation is the process of combining data and functions into a single unit called class.
The concept of abstraction relates to the idea of hiding data that is not needed for presentation. The main idea behind data abstraction is to give a clear separation between properties of data type and the associated implementation details.
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
A function's signature includes the function's name and the number, order and type of its formal parameters.
A. Abstraction
B. Polymorphism
C. Encapsulation
D. Concoction
Polymorphism is the ability to use an operator or method in different ways. Polymorphism gives different meanings or functions to the operators or methods. Poly, referring to many, signifies the many uses of these operators and methods. A single method usage or an operator functioning in many ways can be called polymorphism.
A. Representing essential features
B. Bundling data and functions together
C. An entity with some properties
D. Ability to process data in different ways
Polymorphism is the ability to use an operator or method in different ways. Polymorphism gives different meanings or functions to the operators or methods. Poly, referring to many, signifies the many uses of these operators and methods. A single method usage or an operator functioning in many ways can be called polymorphism. Polymorphism refers to codes, operations or objects that behave differently in different contexts.
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 the process by which new classes called derived classes are created from existing classes called base classes. The derived classes have all the features of the base class and the programmer can choose to add new features specific to the newly created derived class.
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 concept in C++. In C Language Struct can not hide data of its data members. Where as in C++, we got the luxary of hiding data using e different access levels - private, protected, public
A. Ability to be in different forms
B. Representing essential features
C. Bundling data and functions together
D. Process of argument matching
Data encapsulation, sometimes referred to as data hiding, is the mechanism whereby the implementation details of a class are kept hidden from the user. The user can only perform a restricted set of operations on the hidden members of the class by executing special functions commonly called methods.
A. Representing essential features
B. Bundling data and functions together
C. An entity with some properties
D. Ability to be in different forms
Abstraction is an important feature of Object Oriented programming. It refers to representing essential features, ignoring background details.
A. Object Obscured programming
B. Object Oriented programming
C. Procedural programming
D. Logical programming
Object Oriented programming supports features of Object Based programming along with polymorphism and inheritance.
A. Encapsulation
B. Polymorphism
C. Classes
D. Abstraction
As polymorphism is not supported, overloading and inheritance too are not possible.
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. An approach to programming
B. An outdated programming language
C. Software to analyze a problem
D. A group of expert programmers
Programming paradigm is an approach to programming.
A. procedural programming.
B. object oriented programming.
C. object function programming.
D. structural programming.
Object oriented programming offers all features of object based programming and removes the limitation by implementing inheritance and polymorphism.
A. Representing essential features
B. Bundling data and functions together
C. An entity with some properties
D. Ability to process data in different ways
In simple terms Polymorphism is known as more than one form. C++ acquire polymorphism using Overloading and Virtual Function.
A. it’s inability to represent real world relationships.
B. that it overcomes shortcomings of procedural programming.
C. that it hides implementation details from users.
D. that it does not implement abstraction and information hiding.
Object based programming does not support inheritance. For example, both car and truck are vehicles, they cannot be represented in object-based programming.
A. data.
B. method.
C. variable.
D. scope resolution operator.
A class is a collection of data members and member functions. The functions defined within a class, are called member functions or methods.
A. without argument list.
B. matched argument list.
C. same argument list.
D. different argument list.
There are some of the major restrictions on function overloading. Here any two functions in a set of overloaded functions must have different argument list.
A. derived class.
B. base class.
C. super class.
D. inheritable class.
The capability of one class to inherit the properties of the other class is called inheritance. The class which is inherited is called the base class or the super class and the class which inherits from the other class is a derived class or a sub class.
A. derived class.
B. sub class.
C. super class.
D. inheritable class.
The capability of one class to inherit the properties of other class is called inheritance. The class which is inherited is called the base class or super class and the class which inherits from other class is derived class or sub class.
A. process of ambiguation.
B. process of disambiguation.
C. process of matching.
D. procedural ambiguity.
Argument matching involves comparing the actual arguments of the call with the formal parameters of each declared instance of the function. It removes ambiguity.
A. not an essential principal of system design.
B. a conventional programming approach.
C. same as data abstraction.
D. a way to implement data abstraction.
Encapsulation is wrapping up of data and functions into a single unit and it is a way to implement polymorphism.
A. data than the work performed on it.
B. doing things rather than on data itself.
C. objects and classes.
D. principles of data hiding, abstraction and encapsulation.
Procedural programming aims at procedures. It is a list of instructions telling a computer, step by step, what to do, usually having a linear order of execution from the first statement to the second.
A. Abstraction
B. Encapsulation
C. Polymorphism
D. Inheritance
Polymorphism, refers to the "many forms". Here different behaviour is the outcome of the changing situation.
A. Abstraction
B. Polymorphism
C. Encapsulation
D. Inheritance
Same person changes its bevaviour in changing situation. It refers to the feature Polymorphism, i.e., mamy forms.
A. Abstraction
B. Polymorphism
C. Encapsulation
D. Inheritance
Inheritance, car and bicycle both are vehicles, one powered by a motor and the other by human effort.
A. Abstraction
B. Polymorphism
C. Encapsulation
D. Data Hiding
Abstraction, does not include unnecessary details.
A. There is no error
B. Function signatures are different
C. Function signatures are same
D. Function calls are not in the right order
The functions' signatures must be different, return type is not part of this.
A. A27Aa2
B. A27aA2
C. A27A2
D. A27Aa1
A27Aa1 Match the function calls with prototype, don’t miss that the t gets the value returned from funct( )
A. A65 10 23.5 Look Out!
B. A65A1023.5Look Out!
C. 65 A 10 23.5Look Out!
D. A65 A 10 23Look Out!
A65A1023.5Look Out! Match the function calls with prototype, also, ‘A’ as integer will show ASCII of A , which is 65
A. i and ii
B. iii and iv
C. i and iv
D. ii and iii
i and ii, because of the presence of virtual function.
A. To link objects to data
B. At compile time
C. At run time
D. To bind data to functions
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 is done at compile time, as compiler can match function call with function definition.
A. i & ii
B. all of the above
C. none of the above
D. ii & iii
Polymorphism is the attribute that allows one interface to be used with different situation. C++ implements polymorphism through virtual functions, through overloaded functions and overloaded operators.
A. 1 & i, 2 & ii, 3 & iii
B. 1 & ii, 2 & iii, 3 & i
C. 1 & iii, 2 & i, 3 & ii
D. 1 & iii, 2 & ii, 3 & i
1 & iii, 2 & i, 3 & ii arguments in function call and prototype match.
A. Operator overloading
B. Function overloading
C. Simple inheritance
D. Virtual functions
Function overloading, the same function has three different signatures and definitions.
A. one instance.
B. one or two instances.
C. multiple instances.
D. zero instances.
Abstract classes cannot be instantiated. Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but does not contain any implementation.
A. declare-define-use.
B. public functions and private variables.
C. top down programming.
D. bottom up programming.
In bottom-up approach, the individual base elements of the system are first specified in great detail. These elements are then linked together to form larger subsystems. Object-oriented programming uses the concept of objects and classes.
A. semicolon should be used instead of commas.
B. there should be a semicolon at the end of the statement.
C. there is no error.
D. the increment should always be ++k.
In the for loop the proper syntax is for (initialization; condition; increment). So it should be for (k=0; k <10; k++).
A. logical operator && cannot be used with while statement.
B. while loop is an exit condition loop.
C. test condition is always false.
D. test condition is always true.
Here the condition is always false, as i cannot be less than 10 and greater than 24 at the same time. Hence, it will never be true.
A. i=i+1.
B. i=i-1.
C. i=i+i.
D. i=i+0.
-- is a decrement operator which decrements the value of a variable by 1. For example a-- is equal to a=a-1.
A. i=i+1.
B. i=i-1.
C. i=i+i.
D. i=i+0.
++ is an increment operator which increments the value of a variable by 1.
A. for loop.
B. while loop.
C. do while loop.
D. no looping process checks the condition at the end.
In the do while loop, code is executed at least once even if the condition is false.In this loop, the condition is evaluated at the end.
A. //
B. {
C. ;
D. *
C++ supports two types of comments: // single line comment and /* */ Multiple line comment.
A. cin.
B. cout.
C. input.
D. output.
Identifier cout corresponds to the output stream which represents data being displayed to the output screen.
A. cin.
B. cout.
C. input.
D. output.
cin corresponds to the standard input stream which represents data coming from the keyboard.
A. base class.
B. class.
C. derived class.
D. super class.
The derived class, which is also called a subclass, inherits the properties of a base class or super class.
A. get accessed within the class.
B. get accessed outside the class.
C. get accessed within the main() funcion.
D. never accessed.
Private member function and data member can be accessed only within the class in which they are declared.
Bitwise operators are used to perform calculations using binary digits.
A. single inheriance.
B. multi level inheriance.
C. hierarchical inheriance.
D. multiple inheriance.
When a subclass inherits from multiple base classes, it is known as multiple inheritance.
A. 2 types.
B. 4 types.
C. 5 types.
D. 3 types.
There are 5 fundamental data types in C++ : char, int, float, double and void.
A. enter ().
B. output ().
C. start ().
D. main ().
When a program begins running, the system calls the function main which marks the entry point of the program.
A. arrays.
B. bytes .
C. octal numbers.
D. hexadecimal numbers.
Information is stored as a "stream of bytes". Byte-stream files do not have a system-defined record structure.
A. compiler.
B. editors.
C. interpreter.
D. preprocessor
# are preprocessor directives. They are typically used to make source programs easy to change and easy to compile in different execution environments.
A. assigns l value to the r value (left to right rule).
B. assigns r value to the l value (right to left rule).
C. can be used in either way.
D. compares the two values.
The assignment operation always takes place from right to left and never the other way. Example, a=b, this statement assigns to variable a (the l value) the value contained in variable b (the r value).
A. two operands.
B. no operand.
C. one operand.
D. any no of operands.
C++ provides two unary arithmetic operators - unary plus and unary minus. Unary operators operate on only one operand, which could be a constant or a variable.
A. procedural language.
B. object oriented language.
C. object based language.
D. structural language.
Procedural paradigm is a traditional programming that is based on the algorithms.
A. derived class.
B. base class.
C. super class.
D. inheritable class.
The capability of one class to inherit the properties of other class is called as inheritance. The class which is inherited is called the base class or super class and the class which inherits from other class is derived class or sub class.
A. data abstraction.
B. polymorphism.
C. overloading.
D. inheritance.
Polymorphism is the ability for a message or data to be processed in more than one form.
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 an object, is called as instantiation.
A. derived class.
B. sub class.
C. super class.
D. inheritable class.
The capability of one class to inherit the properties of other class is called as inheritance. The class which is inherited is called the base class or super class and the class which inherits from other class is derived class or sub class.
A. process of ambiguation.
B. process of disambiguation.
C. process of matching.
D. procedural ambiguity.
Argument matching involves comparing the actual arguments of the call with the formal parameters of each declared instance of the function. It removes ambiguity.
A. module.
B. abstraction.
C. polymorphism.
D. data.
A group of functions together forms a larger entity called module.
A. not an essential principal of system design.
B. a conventional programming approach.
C. same as data abstraction.
D. a way to implement data abstraction.
Encapsulation is wrapping up of data and functions into a single unit and it is a way to implement polymorphism.
A. data rather than the work performed on it.
B. doing things rather than on data itself.
C. objects and classes.
D. principles of data hiding, abstraction and encapsulation.
Procedural programming aims at procedures. It is a list of instructions telling a computer, step by step, what to do, usually having a linear order of execution from the first statement to the second.
A. procedural programming.
B. object oriented programming.
C. object function programming.
D. structural programming.
Object oriented programming offers all features of object based programming and removes the limitation by implementing inheritance and polymorphism as well.
A. it’s inability to represent real world relationships.
B. that it overcomes shortcomings of procedural programming.
C. that it hides implementation details from users.
D. that it does not implement abstraction and information hiding.
Object based programming does not support inheritance. For example, both car and truck are vehicles, they cannot be represented in object-based programming.
A. by searching for exact match, a match through promotion, a match through standard conversion, a match through user defined conversion.
B. by searching for a match through promotion, a match through standard conversion, a match through user defined conversion.
C. by searching for exact match, a match through standard conversion, a match through user defined conversion.
D. by searching for exact match,then a match through promotion.
The sequence is by searching for exact match, a match through promotion, a match through standard conversion, a match through user defined conversion. A call to an overloaded function is resolved to a particular instance of the function through argument matching.
A. information hiding.
B. inheritance.
C. redefinition.
D. overloading.
A type of polymorphism, where different functions with the same name are invoked based on the data types of the parameters passed, is called overloading.
A. call matching.
B. definition matching .
C. declaration matching.
D. argument matching.
Argument matching involves comparing the actual arguments of the call with the formal parameters of each declared instance of the function.
A. class.
B. abstract class.
C. Base class.
D. Derived class.
An abstract class defined an interface but does not provide implementation details.
A. the second is treated as a re-declaration of first.
B. it is a compile time error.
C. it is a runtime error.
D. the second is treated as a different function.
Overloading is done on functions of same name, having different signatures. When a function has same number of arguments and same type of arguments in the same order, they are said to have the same signature.
A. data type.
B. typedef.
C. signified.
D. same name.
Typedef declarations do not define new types; they introduce synonyms for existing types. They do not affect the overloading mechanism.
A. function inheritance.
B. function overloading.
C. function overriding.
D. function polymorphism.
Function Overloading is a feature using which we can implement Polymorphism. In function overloading we can define more than one function of same name with different arguments.
A. virtual function.
B. overloaded function.
C. overloaded operator.
D. polymorphic function.
Virtual functions allow the programmer to declare functions in a base class that can be redefined in each derived class.
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. information hiding.
B. inheritance.
C. redefinition.
D. overloading.
A type of polymorphism, where different functions with the same name are invoked based on the data types of the parameters passed, is called overloading.
A. call matching.
B. definition matching .
C. declaration matching.
D. argument matching.
Argument matching involves comparing the actual arguments of the call with the formal parameters of each declared instance of the function.
A. Object and Classes.
B. Inheritance.
C. Data Hiding.
D. Polymorphism.
Data Hiding is a concept related to data abstraction. Unessential features or background details are hidden from the world.
A. the second is treated as a re-declaration of first.
B. it is a compile time error.
C. it is a runtime error.
D. the second is treated as a different function.
Overloading is done to create functions of same name with different signatures. When a function has same number of arguments and same type of arguments in the same order, they are said to have the same signature.
A. the second is treated as a re-declaration of first.
B. it is a compile time error.
C. it is a runtime error.
D. the second is treated as a different function.
The second function declaration is treated as as an erroneous re-declaration of the first function and is flagged at compile time as an error.
A. function inheritance.
B. function overloading.
C. function overriding.
D. function polymorphism.
Overloaded functions have same name with different arguments.
A. virtual function.
B. overloaded function.
C. overloaded operator.
D. polymorphic function.