Top Banner
Chapter I: Principles of Object-Oriented Programming 1. Which of the following languages is not a procedure-oriented programming language? a) ALGOL b) COBOL c) FORTRAN d) None of the above 2. Which of the following programming approach used functions as a key concept to perform action-oriented tasks? a) Structured programming b) Modular programming c) Procedure-oriented programming d) Object-oriented programming 3. Identify the drawback of using procedure-oriented programming, if any: a) Data is hidden from external functions b) New functions can be added whenever necessary c) Does not reflect real world problems d) All of the above 4. Which is not associated with Object-oriented programming? a) Data abstraction b) Automatic initialization c) Dynamic binding d) None 5. The term operator overloading in C++ refers to: a) Inheritance b) Message passing c) Polymorphism d) None 6. Which one of the following OOP concepts enables reusability of components? a) Inheritance b) Encapsulation c) Polymorphism d) All of the above 7. The concept of hierarchical classification is related to: a) Abstraction b) Inheritance c) Function overloading d) None 8. Object-based programming languages do not support: i. Inheritance ii. Dynamic binding iii. Encapsulation iv. All of the above a) Both i and ii b) iii only c) iv only d) i, ii, and iii 9. C++ does not support
46
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • Chapter I: Principles of Object-Oriented Programming

    1. Which of the following languages is not a procedure-oriented programming language? a) ALGOL b) COBOL c) FORTRAN d) None of the above

    2. Which of the following programming approach used functions as a key concept to

    perform action-oriented tasks? a) Structured programming b) Modular programming c) Procedure-oriented programming d) Object-oriented programming

    3. Identify the drawback of using procedure-oriented programming, if any:

    a) Data is hidden from external functions b) New functions can be added whenever necessary c) Does not reflect real world problems d) All of the above

    4. Which is not associated with Object-oriented programming?

    a) Data abstraction b) Automatic initialization c) Dynamic binding d) None

    5. The term operator overloading in C++ refers to:

    a) Inheritance b) Message passing c) Polymorphism d) None

    6. Which one of the following OOP concepts enables reusability of components?

    a) Inheritance b) Encapsulation c) Polymorphism d) All of the above

    7. The concept of hierarchical classification is related to:

    a) Abstraction b) Inheritance c) Function overloading d) None

    8. Object-based programming languages do not support:

    i. Inheritance ii. Dynamic binding iii. Encapsulation iv. All of the above

    a) Both i and ii b) iii only c) iv only d) i, ii, and iii

    9. C++ does not support

  • i. Genericity ii. Early binding iii. Garbage collection iv. Multiple Inheritance

    a) i only b) ii only c) iii only d) ii, iii and iv

    10. Which of the following is an Object-oriented programming language?

    i. Smalltalk ii. Object Pascal iii. Java iv. All of the above

    a) Both ii and iii b) i only c) iii only d) iv only

  • Chapter II: Beginning With C++

    1. Which one of the following options is true on the topic of Simula67?

    i. It is the first Object-oriented programming language

    ii. Its a predecessor to C++

    iii. It was designed for doing simulations

    iv. All of the above

    a) Both i and ii

    b) i only

    c) iii only

    d) iv only

    2. Which of the following features that distinguish object oriented programming from other

    conventional programming?

    i. Structural design

    ii. Inheritance

    iii. Modular programming

    iv. bottom-up

    a) i only

    b) Both ii and iii

    c) Both ii and iv

    d) iv only

    3. Comments in C++ starts with _______ symbol.

    a) //

    b) \\

    c) **

    d) None of the above

    4. The insertion operator is another name for

    a) input operator

    b) output operator

    c) extraction operator

    d) None of the above

    5. Which header file in C++ does contain function prototypes for memory allocation?

    a)

    b)

  • c)

    d)

    6. What is the output of the following code?

    int n=10;

    while (n

  • Chapter III: Tokens, Expressions and Control Structures

    1. return is an example of a

    a) Keyword

    b) Function

    c) Statement

    d) Comment

    2. Which of the following is not a keyword?

    i. for

    ii. friend

    iii. virtual

    iv. private

    a) i only

    b) Both ii and iii

    c) Both i and iv

    d) ii, iii and iv

    3. Identify the valid variable name from the following:

    i. char

    ii. var_name

    iii. _varname

    iv. str_name2

    a) Both i and iii

    b) Both ii and iv

    c) ii, iii, and iv

    d) i only

    4. Which of the following is not a user-defined data type?

    a) array

    b) structure

    c) union

    d) class

    5. Write the equivalent C++ statement for the following expression,

    X= ba *c/d a) X=sqrt(a+b) *(c/d);

    b) X=(squareroot(a+b)*c)/d;

    c) X=( )( ba * c)/d; d) None of the above

    6. The statement int main() is a ___________.

  • a) function prototype

    b) function call

    c) function header line

    d) None of the above

    7. The declaration of global variables must be made

    a) inside the function

    b) outside the function

    c) in a function header line

    d) None of the above

    8. Identify the error, if any:

    double avg=tot/n;

    a) Declaration should not contain any expression

    b) Initialization cannot be done in the declaration statement

    c) Dynamic initialization is not possible

    d) No error

    9. Which of the following is true about scope resolution operator?

    a) Qualifies a namespace member to its namespace

    b) Allows you to access a global variable

    c) Qualifies the hidden variable

    d) All of the above

    10. Which of the following is not a member-dereferencing operator?

    a) ::*

    b) ::

    c) *

    d) * 11. Which of the following is true about new operator?

    i. While using new operator, sizeof() operator is not needed

    ii. It is also not necessary to use cast operator

    iii. new operator can be overloaded

    iv. All of the above

    a) Both i and ii

    b) Both i and iii

    c) ii only

    d) iv only

    12. Identify the manipulators in C++:

    a) endl

    b) setw

  • c) Both a and b

    d) None of the above

    13. a = (b = 5); The C++ statement is an example of

    a) Compound assignment

    b) Embedded assignment

    c) Chained assignment

    d) Multiple assignment

    14. Water-fall model is associated with

    a) Control structures

    b) Type conversions

    c) Manipulators

    d) None of the above

    15. Selection structure is also known by

    a) branching

    b) straight line

    c) iteration

    d) None of the above

    16. Consider the following code:

    cout

  • Chapter IV: Functions in C++

    1. Which of the following is true about a function call in a C++ program?

    a) A function must be called atleast once

    b) A function cannot be called from other functions

    c) A function may be called whenever it is necessary

    d) Both a and c

    2. Function prototyping defines

    a) The return type of the function

    b) The identifier of the function

    c) The number and type of arguments

    d) All of the above

    3. Find if the following function prototype contains any error:

    double area(int )

    a) No error

    b) Variable name is not included in the argument list

    c) Semicolon is not found

    d) None of the above

    4. Identify which function prototype exhibits the following: Name of the function is

    sample_calc, which receives two values of type double and returns no value;

    a) sample_calc(double, double);

    b) void sample_calc(double, double);

    c) double sample_calc(void);

    d) void sample_calc(double, double)

    5. When you call a function by passing the address of a data variable, it is called ________.

    a) Call by reference

    b) Call by value

    c) Call by two directions

    d) Both b and c

    6. Which of the following function calls is correct while providing default arguments:

    I. double calc(int a, float b=12.0);

    II. double calc(int a=3, float b=12.0, int c);

    III. double calc(int a=3, float b, int c=8);

    IV. double calc(int a, float b=12.0, int c=8);

    a) I only

    b) II only

    c) Both I and IV

    d) Both II, and III

  • 7. Which function call does invoke the following function prototype?

    float sub1(int a, float b);

    a) X=sub1(5.0,6.5);

    b) X=sub1(5,6.5);

    c) X=sub1(5,6);

    d) Both b and c

    8. Identify the variables, which are local to the following function:

    int calc(int p, int n)

    {

    int q;

    q=pow(p,n);

    return(q);

    }

    a) p and n

    b) p,n, and q

    c) q

    d) Cannot be determined without the main() function

    9. Which of the following statements is true about the function that contains the const

    argument?

    a) The function should not modify the const argument

    b) Const declaration is necessary only when the arguments are passed by

    reference

    c) Both b and c

    d) None of the above

    10. Which of the following functions in C++ replace the usage of macros in C?

    a) friend function

    b) virtual function

    c) inline function

    d) All of the above

  • Chapter V: Classes and Objects

    1. The declaration of a class includes

    a) Declaration of data members

    b) Declaration of function prototype

    c) Return statements of functions

    d) Both a and b

    2. By default, the members of a class are

    a) private

    b) public

    c) protected

    d) static

    3. Which OOP feature can be enabled by using private declaration for the class members?

    a) Data abstraction

    b) Polymorphism

    c) Encapsulation

    d) Modularity

    4. Which of the following will assign the value to the class member variable num? void getnum(int a)

    a) {num=a};

    b) {num=a;}

    c) {a=num};

    d) {a=num;}

    5. Which of the following is not true about member functions?

    a) Can access private data variables

    b) Can call another function directly without using dot operator

    c) Both a and b

    d) None of the above

    6. Identify all the members of the following class xyz: class xyz {

    int x,y; public:

    xyz(); void calc(int a, int b); void output_calc(void);

    }; a) Data members x and y

  • b) Data members x and y, Constructor, and member functions calc() and

    output_calc()

    c) Data members x and y, and member functions calc() and output_calc()

    d) Constructor and member functions calc() and output_calc()

    7. Which of the following is not true about static member variable?

    a) Only one instance of static member can be created

    b) Visible only within the class

    c) It can be initialized whenever necessary

    d) Both a and b

    8. What is the general format of calling a static member function using a class name?

    a) class-name :: function-name

    b) function-name :: class-name

    c) class-name :: function-name;

    d) function-name :: class-name;

    9. Which of the following is true while passing objects as function arguments? It is possible

    a) to pass copy of the entire object to the function

    b) to pass only the address of the object to the function

    c) to pass the objects to a non-member function

    d) All of the above

    10. A friend function

    I. Can be invoked similar to other functions without using objects

    II. Cannot access to other member functions directly

    III. Cannot be called using the object of the class to which it has been

    declared as friend

    IV. Can be declared only in the public part of a class

    a) I, II and III

    b) I, II and IV

    c) I, II, III and IV

    d) IV only

  • Chapter VI: Constructors and Destructors

    1. Which of the following is not true about constructors and destructors?

    a) They must have the same name as class

    b) They cannot return values

    c) They cannot be called more than once in a program

    d) They are called automatically

    2. The default constructor for class A is

    a) A :: A()

    b) A :: A(int)

    c) A :: A(int);

    d) A :: A();

    3. Which of the following statements do correctly describe the characteristics of

    constructors?

    I. They cannot be inherited

    II. They cannot be virtual

    III. They need not be declared in the public section

    IV. We cannot refer to their addresses

    a) Both I and II

    b) I, II, and IV

    c) Both II and III

    d) I, III and IV

    4. Which of the following is called an implicit constructor for the class xyz?

    a) xyz(){ }

    b) xyz(int){}

    c) xyz(){ };

    d) None of the above

    5. Consider the following code segment: class simple {

    int a,b; public:

    simple(); simple(char[]);

    }; Which of the following would assigns the string welcome to the second constructor?

    a) simple s(welcome);

    b) simple s(welcome);

  • c) simple s=welcome;

    d) None of the above

    6. Identify if any error in the following code segment 1. class example 2. { 3. float x; 4. public: 5. void example(); 6. example(int, float); 7. };

    a) Line 7 should not include the semicolon

    b) Line 6 is an incorrect statement

    c) Line 5 cannot include void

    d) No error

    7. Which of the following statements are true about copy constructors?

    I. It declares and initializes an object from another object

    II. It will not be useful when arguments are passed by value

    III. It can be used to pass arguments by reference

    IV. The compiler provides its own copy constructor, if it is not defined.

    a) I, II, IV

    b) All are correct

    c) Both II and III

    d) III only

    8. The following statement creates a constant object of a class simple: const simple m(a,b);

    Which the following is true regarding the above statement?

    a) The compiler generates compile-time error if you try to change the values of a

    and b

    b) Const member is a function prototype

    c) The compiler generates an error if m tries to invoke non-const member functions

    d) All of the above

    9. Which of the following statements do incorrectly describe the characteristics of

    destructors?

    I. A destructor is a member function, which has the same name as class

    name

    II. A destructor receives only one argument

    III. A destructor does not return any value

  • IV. Usage of destructors in a program clean up memory space that is not

    used

    a) Both I and II

    b) All are incorrect

    c) Both II and III

    d) I, II and IV

    10. Which of the following is a correct description of the destructor sample and includes

    output statements (if possible)?

    a) sample :: ~sample() {cout

  • Chapter VII: Operator Overloading and Type Conversions

    1. Which of the following operators cannot be overloaded?

    a) ?:

    b) ::

    c) .*

    d) All of the above

    2. Operator Overloading is also known by the term

    a) runtime polymorphism

    b) compile-time polymorphism

    c) Both a and b

    d) None of the above

    3. Operator overloading is necessary because

    a) C++ attempts to make the user-defined classes act like built-in types

    b) To provide new definitions for most of the C++ operators

    c) To add user-defined data type like basic data types

    d) All of the above

    4. Which of the following is required to overload an operator in C++?

    a) operator function

    b) built-in function

    c) Both a and b

    d) None of the above

    5. Identify the correct definition of an operator function for the class sample, which

    overloads a unary minus operator and returns no values.

    a) sample :: oper-() { };

    b) void sample :: operator-() { }

    c) void sample :: operator-() { };

    d) sample :: operator-() { }

    6. Which of the following is not true about the code segment given below? float sample :: operator +(float x) {// code }

    a) It receives only one float type argument explicitly

    b) It returns a float type value

    c) It is a member function of sample

    d) None of the above

    7. Which of the following operators cannot use friend functions for overloading?

    I. ==

    II. ( )

    III. [ ]

  • IV. ->

    a) I only

    b) II only

    c) II, III and IV

    d) I, II and III

    8. Which of the following is not true about operator overloading?

    a) Only existing operators can be overloaded

    b) Binary arithmetic operators (+,-,*,/) need not return a value

    c) It is impossible to redefine an operator

    d) All of the above

    9. Which of the following code segments will convert a class object namely sample to type

    double?

    a) sample :: operator double() { }

    b) operator double() { }

    c) sample :: operator double();

    d) operator double();

    10. Which of the following statements does correctly describe the casting operator function?

    a) It must not specify return type

    b) It must be a class member

    c) It must not have any arguments

    d) All of the above

  • Chapter VIII: Inheritance: Extending Classes

    1. Which of the following OOP concepts is supported by Inheritance?

    a) Abstraction

    b) Encapsulation

    c) Reusability

    d) None of the above

    2. Which of the following does a derived class inherit from a base class?

    a) public and protected class members

    b) public and private class members

    c) only public data

    d) Everything

    3. Which of the following statement(s) is true, if a derived class is publicly inherited from a

    base class?

    I. The public members of the base class become public members of the

    derived class

    II. The public members of the base class become private members of the

    derived class

    III. The public members of the base class are inaccessible to the objects of

    the derived class

    IV. All of the above

    a) I only

    b) Both I and II

    c) Both I and III

    d) IV only

    4. Consider the following code segment: class A {

    int a; public:

    int b; void inp();

    } class B : A { // members of B }

  • Which of the following statement(s) is NOT true regarding the above code?

    a) The public members, namely b and inp() of class A become private members of

    class B

    b) The public members, namely b and inp() of class A can be accessed by the

    member functions of class B

    c) The public members, namely b and inp() of class A are inaccessible to the

    objects of class B

    d) None of the above

    5. According to the following code, which of the following class members does the derived

    class inherit from the base class? class base {

    float x; int y;

    public: int a; void get_a(); void put_a();

    } class derived : public base { // members of B }

    a) float x

    b) int y

    c) get_a(), void put_a()

    d) All of the above

    6. Which of the following statement(s) is true about the visibility of inherited members?

    a) When a class is inherited in protected mode, the private members of the base

    class become protected members of the derived class

    b) When a class is inherited in private mode, only the public members of the base

    class can be inherited to the derived class

    c) When a class is inherited in public mode, the private members of the base class

    cannot be inherited

    d) None of the above

    7. What are the visibility modifiers available in C++?

    a) public

    b) private

  • c) protected

    d) All of the above

    8. Which of the following functions can have access to the private and protected members

    of a class?

    a) A member function of a class that is a friend of the class

    b) A member function of a derived class

    c) A function that is a friend of the class

    d) All of the above

    9. Consider the following code segment: class B : public A {

    int a; public:

    int b; void a_inp(); void a_out();

    } class C : public A { private: float x; public: double get_calc(); double put_calc(); }

    Which of the following statement(s) is true regarding the above code?

    a) Class A is the parent class of both the classes B and C; and class B inherits

    get_calc() from class C

    b) Class A is the parent class of both the classes B and C, which do not have any

    relationship between them

    c) Two classes cannot be the child classes of the same base class

    d) Class A is the parent class of both the classes B and C; and class C inherits

    a_out() from class B

    10. Consider the following code segment: class Book {..}; class Prose : public Book {.}; class Poetry : public Prose {.};

    The above code is an example of

  • a) Multiple Inheritance

    b) Multilevel Inheritance

    c) Hierarchical Inheritance

    d) Hybrid Inheritance

    11. Consider a class D, which is inherited from two classes B and C. The classes B and C

    inherited the members from class A. Which feature of C++ does allow you to handle such

    kind of mulitpath inheritance?

    a) Abstract class

    b) Virtual base class

    c) Duplicate class

    d) None of the above

    12. If a class contains the objects of another class as its members, then it is known as

    a) Containership

    b) Private inheritance

    c) Dynamic notation

    d) None of the above

  • Chapter IX: Pointers, Virtual Functions and Polymorphism

    1. Which of the following is true about pointers?

    a) A pointer is a data type

    b) A pointer is a keyword

    c) A special type of integer variable

    d) None of the above

    2. Which of the following statement(s) is true according to the following statement? p=*ptr;

    a) p must be a pointer variable

    b) The value of ptr is assigned to the variable p

    c) The address of the pointer ptr is assigned to the variable p

    d) The value of the variable that the pointer ptr is pointing to is assigned to the

    variable p

    3. Compile time polymorphism is also known as

    a) early binding

    b) static binding

    c) static linking

    d) All of the above

    4. C++ supports a mechanism virtual function to achieve

    a) compile time polymorphism

    b) function overloading

    c) run time polymorphism

    d) operator overloading

    5. Which of the following is NOT true about virtual functions?

    I. They cannot be static members

    II. A virtual function can be a friend of another class

    III. We can have virtual constructors, but we cannot have virtual destructors

    IV. They are accessed by using object pointers

    a) II only

    b) III only

    c) Both II and III

    d) I, II and IV

    6. Consider the following code segment: int main() {

    int x, *x_ptr=&x; x=5;

  • x_ptr=NULL; cout
  • class A { public: virtual void disp() { cout
  • Chapter X: Managing Console I/O Operations

    1. Which of the following is not an input/output stream class?

    a) ios

    b) istream

    c) ostream

    d) None of the above

    2. Which class does define the member function put()?

    a) istream

    b) ostream

    c) streambuf

    d) None of the above

    3. Which of the following code would read a line of text from char type variable, book[20]?

    a) cin.getline(book,20);

    b) cin.getline(book[20]);

    c) cin.getln(book,20);

    d) None of the above

    4. What would be the output of the following code?

    char *str= Managing Console I/O Operations; cout.write(str,15);

    a) Managing Console I/O Operations

    b) Managing C

    c) Managing Consol

    d) None of the above

    5. Which of the following feature does allow you to format the output in C++?

    a) Manipulators

    b) ios class functions and flags

    c) User-defined output functions

    d) All of the above

    6. Which of the following functions allow you clear the specified flags?

    a) fill()

    b) unsetf()

    c) cflag()

    d) None of the above

    7. What would be the output of the following code? cout.width(5); cout.precision(2); cout

  • a) 846.20

    b) 846.21

    c) 846.209

    d) 846.2

    8. Identify the equivalent ios function for the manipulator setw.

    a) width()

    b) setwidth()

    c) swidth()

    d) None of the above

    9. What would be the output of the following code? cout.fill($); cout.setf(ios::left, ios:: adjustfield); cout.width(20); cout

  • Chapter XI: Working with Files

    1. All file stream classes are derived from

    a) ifstream

    b) fstreambase

    c) ifstreambase

    d) ofstreambase

    2. Which of the following stream classes provide support for simultaneous input and output

    operations?

    a) ifstream

    b) ofstream

    c) fstream

    d) None of the above

    3. Which of the following statement(s) creates an output stream object called out_strobj and

    opens a file named sample?

    a) ofstream out_strobj(sample);

    b) ofstream out_strobj(sample);

    c) ostream out_strobj(sample);

    d) ostream out_strobj(sample);

    4. Which of the following function(s) opens a file named sample for writing only?

    a) ofstream_object.open(sample, ios::app);

    b) ifstream_object.open(sample, ios::out);

    c) ofstream_object.open(sample, ios::out);

    d) ifstream_object.open(sample, ios::app);

    5. Consider the following code segment: 1: void main() 2: { 3: char line[80],str[80]; 4: str = "Working with C++ files"; 5: ofstream fout;

    6: fout.open("sample.txt",ios::out); 7: fout

  • c) Line 3

    d) Line 8

    6. Consider a file named sample.txt contains the string Working with C++ files. Now the

    following code attempts to read the file. void main() {

    char line[80]; ifstream fin; fin.open(sample.txt,ios::in); fin>>line; cout

  • 8. Assume that the file pointer points to the byte number 22. Now consider the following

    code segment: fout.seekg(2,ios::beg); fout.seekg(-4,ios::beg); int k=fout.tellg(); cout

  • Chapter XII: Templates

    1. C++ Templates support the concept of

    I. modular programming

    II. generic programming

    III. structural programming

    IV. None of the above

    2. Which of the following is NOT true about Templates?

    I. They allow you to define generic classes

    II. Template type can be substituted by any data-type

    III. They eliminate code duplication for different data types

    IV. None of the above

    3. Consider the following code segment: template class sample { ..//code };

    Identify the correct syntax for declaring a dynamic array of characters using the above

    template.

    I. sample characterArray;

    II. sample characterArray;

    III. temp characterArray;

    IV. temp characterArray;

    4. Which of the following statement(s) defines more than one generic data type in a class

    template?

    I. template

    II. template

    III. template

    IV. template

    5. Consider the following code segment: template void sample(temp &x) { .//code };

    Which of the following is true about the above code?

  • I. Declares a sample() class template that receives the given data type for a single

    value and returns no value

    II. Declares a temp function template that receives the given data type for a single

    value

    III. Declares a sample() function template that receives a value of given data type and

    returns no value

    IV. None of the above

    6. Which of the following are not the advantages of class templates in C++?

    I. One C++ class template can handle different types of parameters

    II. Testing and debugging efforts are reduced

    III. It allows the process of instantiation

    IV. None of the above

    7. Consider the following code segment: 1: template 2: void show(temp1 a, temp2 b) 3: { 4: cout

  • c) 100

    d) None of the above

    9. Which of the following statement(s) is similar to the declaration of non-type template

    parameters?

    a) Pointer to member

    b) Pointer to object or pointer to function

    c) Reference to object or reference to function

    d) All of the above

    10. Consider the declaration of a template non-type argument in the following code snippet: template class sample { temp a[max]; static int b=50; // }

    Which of the following statement(s) does not invoke the above template correctly?

    I. sample x;

    II. sample20> x;

    III. sample20)> x;

    IV. sample x;

    a) I only

    b) III only

    c) Both II and IV

    d) Both I and III

  • Chapter XIII: Exception Handling

    1. Which of the following error occur due to poor understanding of the language?

    a) Logical error

    b) Run-Time error

    c) Syntax error

    d) Program error

    2. Which block handles the exception?

    a) Finally block

    b) Catch block

    c) Try block

    d) None of the above

    3. Which of the following statement(s) is true about try block?

    I. The try block is immediately followed by the catch block.

    II. Try statement can have only one catch statement.

    III. A program segment can have more than one catch statement with a try

    statement.

    IV. All of the above

    a) I only

    b) Both I and II

    c) Both I and III

    d) IV only

    4. What happens when the try block does not throw any exception?

    a) The program is aborted

    b) Normal execution is completed

    c) Cannot be predicted

    d) None of the above

    5. What will be the output of the following code segment? void function(); int main() { try { function(); } catch (char)

  • { cout
  • throw y; else cout
  • ........ Function body

    ........ }

    c) type function(type-list) throw(type-list) { ........ ........ Function body ........ }

    d) None of the above 10. What will happen if an error is not handled?

    a) Error in compilation

    b) Abrupt program termination

    c) Error in execution

    d) None of the above

  • Chapter XIV: Introduction to the Standard Template Library

    1. Which of the following is not a sequence container available in STL?

    a) vector

    b) deque

    c) array

    d) list

    2. Consider the following code snippet: int main() { vector v1(10); vector v2(10); v1.at(0)=24; v1.at(1)=20; v1.at(2)=38; for(int i=0;i

  • 4. Consider the following code segment: void main() {

    list l1; list l2; l1.push_front(6); l1.push_back(8); l1.push_front(4); l1.push_back(5); l1.push_front(3); l1.reverse(); l1.front()=l1.front()*5; l2=l1; cout

  • a) Line 4

    b) Line 3 & Line 4

    c) Line 8

    d) Line 9

    7. Pick out the correct usage of the list function called, splice().

    a) Deletes a list from the invoking list

    b) Arranges the list elements as specified

    c) Inserts a list into the invoking list

    d) Gives the size of the list

    8. If map_test is a map, map k = map_test;

    Which of the following statement(s) does illustrate the above code correctly?

    I. It will create a new map k whose elements are logical copies of the

    elements of map_test.

    II. It is equivalent to: mapmap_test(k); III. It will create a new map map_test whose elements are logical copies of

    the elements of k.

    IV. It is equivalent to: mapk(map_test); a) I only

    b) IV only

    c) Both II and III

    d) Both I and IV

    9. Consider i is an iterator that accesses the elements of a map. Which of the following will

    be used to access the two entries, namely key and value of the map?

    a) i.first, i.second

    b) (*i).first, (*i).second

    c) *i.first, *i.second

    d) *i.first, (*i).second

    10. Which of the following is NOT true about function objects?

    a) The class, which creates a function object, contains only one overloaded

    operator() function.

    b) Function objects can be used to perform arithmetic and logical operations.

    c) For using function objects, header file is needed.

    d) None of the above

  • Chapter XV: Manipulating Strings

    1. string is a

    a) data-type

    b) class

    c) namespace

    d) function

    2. Which of the following function is used to read a line of text with blanks?

    a) inputline( )

    b) getline( )

    c) putline( )

    d) None the above

    3. Which of the following function is not supported by the string class?

    a) count( )

    b) Assign( )

    c) resize( )

    d) empty( )

    4. Consider the following code segment: void main() { string s1("example"); string s2("2468"); s1.insert(2,s2); s1.erase(3,5); s1.replace(2,3,s2); cout

  • string s1("aabbcc"); string s2("bbccaa"); a = s1.compare(4,2,s2,2,2); b = s1.compare(0,2,s2,0,2); if(a == 0) cout
  • cout
  • Chapter XVI: New Features of ANSI C++ Standard

    1. Which of the following data type(s) is introduced by ANSI C++?

    a) bool

    b) wchar_t

    c) char_t

    d) Both a and b

    2. Consider the following code snippet: .. int p; string s("Pass"); bool k; if(s=="pass") { k=true; } p=true+50+false; cout

  • char *a,b; if(typeid(a)==typeid(b))

    cout

  • I. using namespace samplespace;

    II. using samplespace :: p;

    III. samplespace.p;

    IV. p :: samplespace();

    a) I only

    b) II only

    c) Both III and IV

    d) Both I and II

    10. Write the equivalent expression using operator keywords for the following. (a!=b) > (~(a & b)&=(a^b))

    a) (a not_eq b) gt (not( a bitand b) and_eq (a xor b))

    b) (a not_eq b) > (compl( a bitand b) and_eq (a xor b))

    c) (a not_eq b) gt (not( a bitand b) not_eq (a exor b))

    d) (a not_eq b) > (compl( a bitand b) not_eq (a exor b))

  • Chapter XVII: Object-Oriented Systems Development

    1. Which model of object-oriented paradigm replaces the classic water-fall model of

    procedure-oriented development?

    a) Fountain model

    b) Spiral model

    c) Throwaway prototyping model

    d) None of the above

    2. Functional decomposition technique can be used to implement _________.

    a) Spiral model

    b) Water-fall model

    c) Reuse model

    d) Fountain model

    3. Which of the following is true about object-oriented analysis (OOA) approach?

    a) Identifies the objects and their attributes

    b) Identifies the services that each object is expected to provide

    c) Establishes interconnections between the objects

    d) All of the above

    4. Data flow diagram is also known as________.

    a) Bubble chart

    b) Data flow graph

    c) Both a and b

    d) None of the above

    5. Which of the following can be used to identify the services provided and received by

    objects?

    a) Information Flow Diagram

    b) Entity-Relationship Diagram

    c) Either a or b

    d) Neither a nor b

    6. Which relationship defines is_a relationship in object-oriented design?

    a) Containment relationship

    b) Inheritance relationship

    c) Use relationship

    d) None of the above

    7. Let us assume that there are two classes, namely M and N. Consider the following

    statement:

    M calls a member of N

  • Which object-oriented relationship can provide this information?

    a) Use relationship

    b) Containment relationship

    c) Inheritance relationship

    d) None of the above

    8. Which of the following is associated with the process of a class organization?

    a) Single-tree model

    b) Forest model

    c) Both a and b

    d) None of the above

    9. Which of the following is NOT true about prototyping process?

    a) It is the process of building and testing a working model of the proposed system

    b) It is the process of time consuming and expensive

    c) Both a and b

    d) None of the above

    10. Which of the following can be used to identify the objects in object-oriented design?

    a) Textual analysis

    b) Data flow diagram

    c) Both a and b

    d) None of the above

    Chapter_I_QuestionsChapter I: Principles of Object-Oriented Programming

    Chapter_II_QuestionsChapter II: Beginning With C++

    Chapter_III_QuestionsChapter III: Tokens, Expressions and Control Structures

    Chapter_IV_QuestionsChapter IV: Functions in C++

    Chapter_V_QuestionsChapter V: Classes and Objects

    Chapter_VI_QuestionsChapter VI: Constructors and Destructors

    Chapter_VII_QuestionsChapter VII: Operator Overloading and Type Conversions

    Chapter_VIII_QuestionsChapter VIII: Inheritance: Extending Classes

    Chapter_IX_QuestionsChapter IX: Pointers, Virtual Functions and Polymorphism

    Chapter_X_QuestionsChapter X: Managing Console I/O Operations

    Chapter_XI_QuestionsChapter XI: Working with Files

    Chapter_XII_QuestionsChapter XII: Templates

    Chapter_XIII_QuestionsChapter XIII: Exception Handling

    Chapter_XIV_QuestionsChapter XIV: Introduction to the Standard Template Library

    Chapter_XV_QuestionsChapter XV: Manipulating Strings

    Chapter_XVI_QuestionsChapter XVI: New Features of ANSI C++ Standard

    Chapter_XVII_QuestionsChapter XVII: Object-Oriented Systems Development