A System programs
B C programs
C Shell scripts D None of the above
Answer C
___________________________________________________________________________________________ Which of the following are not filter programs?
A Date B Sort C Cat D Grep Answer A ___________________________________________________________________________________________ Which of the following shell scripts looping features does not recognize the break command?
A While
B Until
C For
D None of the above Answer D
___________________________________________________________________________________________ Which of the following is not a filter?
A cat B wc C grep D sort Answer A ___________________________________________________________________________________________ Shell functions
A Are another name for shell procedures B Execute faster than shell procedures C Are executed by a new shell
D Are not executed by new shell Answer D
The members of a class by default are
A Public B Protected C Private D Mandatory to specify Answer C ___________________________________________________________________________________________
Exception handling is targeted at A Run-time error
B Compile time error C Logical error D All of the above
Answer A
___________________________________________________________________________________________ It is possible to declare as a friend
A A member function B A global function
C A class
D All of the above Answer D
___________________________________________________________________________________________ You separated a derived class name from its access specifier with
A A colon
B Two colons
C Atleast one space
D A semi colon
Answer B
___________________________________________________________________________________________ An exception is caused by
A A hardware problem
B A problem in the operating system C A syntax error
D A run-time error Answer D
___________________________________________________________________________________________ The following can be declared as friend in a class
A An object
B A class
C A public data member D A private data member
Answer B
___________________________________________________________________________________________ Which of the following statements is NOT valid about operator overloading?
A Only existing operators can be overloaded
B Overloaded operator must have at least one operand of its class type C The overloaded operators follow the syntax rules of the original operator D None of the above
Answer D
A copy constructor takes A No argument B One argument C Two arguments
D Arbitrary no. of arguments Answer B
___________________________________________________________________________________________ An object is
A One instance of a class B Another word for a class C A class with static method D A method that accesses class
Answer A
___________________________________________________________________________________________ cfront
A is the front end of a C compiler B is the per-process of a C compiler
C is a tool that is translated a C++ code to its equivalent C code D None of above
Answer C
A class defined within another class is
A Nested class B Inheritance C Containership D Encapsulation Answer A ___________________________________________________________________________________________ A blueprint for a software object is called a
A Object B Class C Instance D None of these Answer B ___________________________________________________________________________________________ At which point of time a variable comes into existence in memory is determined by its
A Scope
B Storage class
C Data type
D All of the above Answer B
A virtual class is the same as A An abstract class
B A class with a virtual function C A base class
D None of the above Answer D
___________________________________________________________________________________________ A static data member is given a value
A Within the class definition B Outside the class definition C When the program is exeuted
D Never
Answer D
___________________________________________________________________________________________ Which of the following is false for cin?
A It represents standard input B It is an object of istream class.
C It is a class of which stream is an object
D Using cin the data can be read from user’s terminal Answer C
___________________________________________________________________________________________ Member functions, when defined within the class specification
A Are always inline B Are not inline
C Are inline by default, unless they are too big or too complicated D Are not inline by default.
Answer A
___________________________________________________________________________________________ Access to private data
A Restricted to methods of the same class B Restricted to methods of other classes
C Available to methods of the same class and other classes D Not an issue because the program will not compile
Answer B
___________________________________________________________________________________________ C++ was originally developed by
A Clocksin and Melish
B Donald E.Knuth
C Sir Richard Hadlee D Bjarne Stroustrup
Answer D
Use of virtual functions implies A Overloading B Overriding C Static binding D Dynamic binding Answer D
Which of the statements is true in a protected derivation of a derived class from a base class? A Private members of the base class become protected members of the derived class
B Protected members of the base class become public members of the derived class C Public members of the base class become protected members of the derived class D Protected derivation does not affect private and protected members of the derived class
Answer C
___________________________________________________________________________________________ The keyword friend does not appear in
A The class allowing access to another class B The class desiring access to another class C The private section of a class
D The public section of a class Answer C
___________________________________________________________________________________________ Data members which are static
A Cannot be assigned a value
B Can only be used in static functions C Cannot be defined in a Union D Can be accessed outside the class
Answer B
___________________________________________________________________________________________ Which can be passed as an argument to a function?
A Constant
B Expression
C Another function D All of the above
Answer A
___________________________________________________________________________________________ Function templates can accept
A Any type of parameters B Only one parameter
C Only parameters of the basic type D Only parameters of the derived type
Answer C
If you wanted to sort many large objects or structures, it would be most efficient to A Place them in an array and sort the array.
B Place pointers to them in an array and sort the array. C Place them in a linked list and sort the linked list. D Place references to them in an array and sort the array. Answer C
___________________________________________________________________________________________ Match the following :
(a) Garbage collection in 1. Java
(b) Nameless object 2. generic programming (c) Template support 3. defines a class (d) A forward reference 4. member function
In which case is it mandatory to provide a destructor in a class? A Almost in every class
B Class for which two or more than two objects will be created C Class for which copy constructor is defined
D Class whose objects will be created dynamically Answer D
___________________________________________________________________________________________ A pointer to the base class can hold address of
A Only base class object B Only derived class object
C Base class object as well as derived class object D None of the above
Answer C
___________________________________________________________________________________________ Member of a class specified as _______ are accessible only to method of the class.
A private B public C protected D derive Answer A ___________________________________________________________________________________________ When a child class function is called,the compiler looks first for a matching function name in the
A Class of the object using the function name B Immediate ancestor class
C Base class D Descendant class
Answer A
___________________________________________________________________________________________ Maximum number of template arguments in a function template is
A One
B Two
C Three
D Many
(e) Derived class inherits from base class
A 1 5 4 2 3 B 1 5 2 3 4 C 5 1 2 3 4 D 5 4 3 1 2 Answer B ___________________________________________________________________________________________ A struct is the same as a class except that
A There are no member functions B All members are public
C Cannot be used in inheritance hierarchy D It does have a this pointer
Answer C
___________________________________________________________________________________________ Which of the following is not the characteristic of constructor?
A They should be declared in the public section. B They do not have return type.
C They can not be inherited. D They can be virtual. Answer D
___________________________________________________________________________________________ The friend functions are used in situations where:
A We want to have access to unrelated classes B Dynamic binding is required
C Exchange of data between classes to take place D None of the above
Answer D
___________________________________________________________________________________________ A template class
A Is designed to be stored in different containers B Works with different data types
C Generates objects which must be identical
D Generates classes with different numbers of member functions Answer B
___________________________________________________________________________________________ Pure virtual functions
A Have to be redefined in the inherited class B Cannot have public access specification C Are mandatory for a virtual class D None of the above
Answer A
___________________________________________________________________________________________ Overloading a postfix increment operator by means of a member function takes
A No argument B One argument C Two arguments D Three arguments Answer A ___________________________________________________________________________________________ A class which can use all the features of an established class,is
A A static class B A super class C A subclass
D Overloaded Answer C
___________________________________________________________________________________________ A friend function to a class, C cannot access
A Private data members and member functions B Public data members and member functions C Protected data members and member functions D The data members of the derived class of C Answer D
In access control in a protected derivation, visibility modes will change as follows A Private, public and protected become protected
B Only public becomes protected
C Public and protected become protected D Only private becomes protected
Answer C
___________________________________________________________________________________________ Which of the following cannot be legitimately passed to a function
A A constant B A variable C A structure D A header file Answer D ___________________________________________________________________________________________ When the compiler cannot differentiate between two overloaded constructors, they are called
A Overloaded B Destructed C Ambiguous D Dubious Answer C ___________________________________________________________________________________________ If a base class destructor is not virtual, then
A It can not have a function body B It can not be called
C It can not be called when accessed from pointer
D Destructor in derived class can not be called when accessed through a pointer to the base class Answer D
___________________________________________________________________________________________ A function call mechanism that passes arguments to a function by passing a copy of the values of the arguments is __________
A Call by name B Call by value C Call by reference D Call by value result Answer B
___________________________________________________________________________________________ A variable defined within a block is visible
A From the point of definition onward in the program B From the point of definition onward in the function C From the point of definition onward in the block D Throughout the function
Answer C
___________________________________________________________________________________________ RunTime polymorphism is achieved by ___________
A Friend function B Virtual function C Operator overloading D Function overloading Answer B ___________________________________________________________________________________________ This pointer
A Implicitly points to an object B Can be explicitly used in a class C Can be used to return an object D All of the above
Answer D
___________________________________________________________________________________________ A __________ is a special method used to initialize the instance variable of a class.
A Member function B Destructor C Constructor D Structure Answer C ___________________________________________________________________________________________ Additional information sent when an exception is thrown may be placed in
A The throw keyword
B The function that caused the error C The catch block
D An object of the exception class Answer C
Mechanism of deriving a class from another derived class is known as____ A Polymorphism B Single Inheritance C Multilevel Inheritance D Message Passing Answer C ___________________________________________________________________________________________ Mechanism of deriving a class from another derived class is known as
A Polymorphism B Single inheritance C Multilevel inheritance D Message passing Answer C ___________________________________________________________________________________________ The concept of hierarchical classification is related to
A Abstraction B Inheritance C Function overloading D None Answer B ___________________________________________________________________________________________ The process of extracting the relevant attributes of an object is known as
A Polymorphism B Inheritence
C Abstraction D Data hiding Answer B
___________________________________________________________________________________________ If a class C is derived from class B, which is derived from class A, all through public inheritance, then a class C member function can access
A Protected and public data only in C and B B Protected and public data only in C C Private data in A and B
D Protected data in A and B Answer D
___________________________________________________________________________________________ The process of building new classes from existing one is called ______.
A Polymorphism B Structure C Inheritance D Cascading Answer C ___________________________________________________________________________________________ This type of inheritance is a mixture of multiple inheritance and hierarchical inheritance
A Single inheritance B Multiple inheritance C Hierarchical inheritance D Hybrid inheritance Answer D ___________________________________________________________________________________________ The base class access specification determines how ___________ members in the base class may be accessed by derived classes. A Private B Public C Protected D A,Band C Answer D ___________________________________________________________________________________________ A base class may also be called a
A Child class B Subclass C Derived class D Parent class Answer D ___________________________________________________________________________________________ In multiple inheritance
A The base classes must have only default constructors B Cannot have virtual functions
C Can include virtual classes D None of the above
Answer C
Which of the statements are true ?
I. Function overloading is done at compile time.
II. Protected members are accessible to the member of derived class. III. A derived class inherits constructors and destructors.
IV. A friend function can be called like a normal function. V. Nested class is a derived class.
A I, II, III B II, III, V C III, IV, V D I, II, IV Answer D ___________________________________________________________________________________________ _________ members of a base class are never accessible to a derived class.
A Public B Private C Protected D A,B and C Answer B ___________________________________________________________________________________________ Assume that we have constructor functions for both base class and derived class. Now consider the declaration in main( ). Base * P = New Derived; in what sequence will the constructor be called ?
A Derived class constructor followed by Base class constructor. B Base class constructor followed by derived class constructor. C Base class constructor will not be called.
D Base class constructor will not be called. Answer B
___________________________________________________________________________________________ When a sub class is inherited from only one super class .It is known as
A Single inheritance B Multiple inheritance C Hierarchical inheritance D Multilevel inheritance Answer A ___________________________________________________________________________________________ In multiple inheritance
A The base classes must have only default constructors B Cannot have virtual functions
C Cannot have virtual classes D None of the above
Answer C
___________________________________________________________________________________________ The polymorphism can be characterized by the phrase
A One interface,multiple methods B Multiple interfaces,one method C One interface,one method D None of the above
Answer A
___________________________________________________________________________________________ The mechanism that binds code and data together and keeps them secure from outside world is known as
A Abstraction B Inheritance C Encapsulation D Polymorphism Answer C ___________________________________________________________________________________________ The term __________ means the ability to take many forms.
A Inheritance B Polymorphism C Member function D Encapsulation
Answer B
___________________________________________________________________________________________ Runtime polymorphism is achieved by
A Friend function B Virtual function C Operator overloading D Function overloading Answer B ___________________________________________________________________________________________ RunTime Polymorphism is achieved by ______
A Friend function B Virtual function C Operator overloading D Function overloading Answer B
Usually a pure virtual function A Has complete function body B Will never be called
C Will be called only to delete an object D Is defined only in derived class
Answer D
___________________________________________________________________________________________ Encapsulation is
A Dynamic binding
B A mechanism to associate the code and data. C Data abstraction
D Creating new class Answer B
___________________________________________________________________________________________ Identify the operator that is NOT used with pointers
A -> B & C * D >> Answer D ___________________________________________________________________________________________
Consider the following statements char *ptr;
ptr = “hello”; cout << *ptr;
What will be printed? A first letter B entire string C it is a syntax error D last letter Answer A ___________________________________________________________________________________________ Which of the following operator can be overloaded through friend function?
A -> B = C ( ) D * Answer D ___________________________________________________________________________________________ What will be the output of the following program?
#include<iostream.h> void main() { float x=5,y=2; int result; result=x % y; cout<<result; } A 1 B 1.0 C Error message D 2.5 Answer C ___________________________________________________________________________________________ Which of the following declarations are illegal?
A void *ptr; B char *str = “hello”; C char str = “hello”; D const *int p1; Answer C ___________________________________________________________________________________________
Which of the following will produce a value 10 if x = 9.7? A floor(x) B abs(x) C log(x) D ceil(x) Answer D ___________________________________________________________________________________________ The address of a variable temp of type float is
A *temp B &temp C float& temp D float temp& Answer B ___________________________________________________________________________________________ What will be the values of x, m and n after the execution of the following statements?
int x, m, n; m = 10; n = 15; x = ++m + n++; A x=25, m=10, n=15 B x=26, m=11, n=16 C x=27, m=11, n=16
If we create a file by ‘ifstream’, then the default mode of the file is _________
A ios :: out B ios :: in C ios :: app D ios :: binary Answer B ___________________________________________________________________________________________ If the variable count exceeds 100, a single statement that prints “Too many” is
A if (count<100) cout << “Too many”; B if (count>100) cout >> “Too many”; C if (count>100) cout << “Too many”; D None of these.
Answer C
___________________________________________________________________________________________ What is the following code segment doing?
void fn( ){ char c; cin.get(c); if (c != ‘\n’) { fn( ); cout.put(c); } }
A The string entered is printed as it is. B The string entered is printed as it is. C It will go in an infinite loop.
D It will print an empty line. Answer B
D x=27, m=10, n=15 Answer B
___________________________________________________________________________________________ for (; ;)
A means the test which is done using some expression is always true B is not valid
C will loop forever
D should be written as for( ) Answer C
___________________________________________________________________________________________ Consider the following statements:
int x = 22,y=15;
x = (x>y) ? (x+y) : (x-y);
What will be the value of x after executing these statements?
A 22 B 37 C 7 D 5 Answer B ___________________________________________________________________________________________ If an array is declared as int a[4] = {3, 0, 1, 2}, then values assigned to a[0] & a[4] will be ________
A 3, 2 B 0, 2 C 3, 0 D 0, 4 Answer C ___________________________________________________________________________________________ To access the public function fbase() in the base class, a statement in a derived class function fder() uses the statement.fbase(); A fbase(); B fder(); C base::fbase(); D der::fder(); Answer A ___________________________________________________________________________________________ If x =5, y =2 then x ^y equals________.
(where ^ is a bitwise XOR operator) A 00000111 B 10000010 C 10100000 D 11001000 Answer A ___________________________________________________________________________________________ What will be the output of following program?
#include<iostream.h> void main() { float x; x=(float)9/2; cout<<x; } A 4.5 B 4.0 C 4
D 5 Answer A
___________________________________________________________________________________________ The operator << when overloaded in a class
A must be a member function B must be a non member function C can be both (A) & (B) above D cannot be overloaded
Answer C
Which of the following is the valid class declaration header for the derived class d with base classes b1 and b2?
A class d : public b1, public b2 B class d : class b1, class b2 C class d : public b1, b2 D class d : b1, b2
Answer A
___________________________________________________________________________________________ In C++, dynamic memory allocation is accomplished with the operator ____
A new B this C malloc( ) D delete Answer A ___________________________________________________________________________________________ What is the error in the following code?
class t {
virtual void print(); }
A No error
B Function print() should be declared as static. C Function print() should be defined.
D Class t should contain data members. Answer A
___________________________________________________________________________________________ What is the output of the following code
char symbol[3]={‘a’,‘b’,‘c’};
for (int index=0; index<3; index++) cout << symbol [index];
A a b c B “abc” C abc D ‘abc’ Answer C ___________________________________________________________________________________________
What will be the result of the expression 13 & 25? A 38 B 25 C 9 D 12 Answer C ___________________________________________________________________________________________ The operator that cannot be overloaded is
A ++
B : :
C ~
D ( )