IT26 - Quiz

Ace your homework & exams now with Quizwiz!

An exception is __ A - Runtime error B - Compile time error C - Logical error D - None of the above

A - Runtime error

A constructor can be virtual. A - True B - False

B - False

Operators sizeof and ?: A - Both can be overloaded B - Both cannot be overloaded C - Only sizeof can be overloaded D - Only ?: can be overloaded

B - Both cannot be overloaded

Following is the invalid inclusion of a file to the current program. Identify it A - #include <file> B - #include "file" C - #include < file D - All of the above are invalid

C - #include < file

What is the outpout of the following program? #include<iostream> using namespace std; main() { enum { india, is = 7, GREAT }; cout<<india<<" "<<GREAT; } A - 0 1 B - 0 2 C - 0 8 D - Compile error

C - 0 8

Choose the operator which cannot be overloaded. A - / B - () C - :: D - %

C - ::

A single line comment in C++ language source code can begin with _____ A - ; B - : C - /* D - //

D - //

A trigraph character begins with A - # B - ## C - ? D - ??

?

A user defined header file is included by following statement in general. A - #include "file.h" B - #include <file.h> C - #include <file> D - #include file.h

A - #include "file.h"

The operator used to access member function of a structure using its object. A - . B - -> C - * D - None of the above

A - .

How many number of arguments can a destructor of a class receives? A - 0 B - 1 C - 2 D - None of the above.

A - 0

What is the output of the following program? #include<iostream> using namespace std; main() { short unsigned int i = 0; cout<<i--; } A - 0 B - Compile error C - 65535 D - 32767

A - 0

What will be the output of the following program? #include<iostream> #include<string.h> using namespace std; main() { cout<<strcmp("strcmp()","strcmp()"); } A - 0 B - 1 C - -1 D - Invalid use of strcmp() function

A - 0

What is the output of the following program? #include<iostream> using namespace std; class abc { public: static int x; int i; abc() { i = ++x; } }; int abc::x; main() { abc m, n, p; cout<<m.x<<" "<<m.i<<endl; } A - 3 1 B - 3 3 C - 1 1 D - 1 3

A - 3 1

What is the output of the following program? #include<iostream> #include<string.h> using namespace std; main() { char s[] = "Hello\0Hi"; cout<<strlen(s)<<" "<<sizeof(s); } A - 5 9 B - 7 20 C - 5 20 D - 8 20

A - 5 9

What is the output of the following program? #include<iostream> using namespace std; class Base { public: void f() { cout<<"Base\n"; } }; class Derived:public Base { public: void f() { cout<<"Derived\n"; } }; main() { Base *p = new Derived(); p->f(); } A - Base B - Derived C - Compile error D - None of the above.

A - Base

What is the output of the following program? #include<iostream> using namespace std; class Base { public: void f() { cout<<"Base\n"; } }; class Derived:public Base { public: void f() { cout<<"Derived\n"; } }; main() { Derived obj; obj.Base::f(); } A - Base B - Derived C - Compile error D - None of the above.

A - Base

How can we make an class act as an interface in C++? A - By only providing all the functions as virtual functions in the class. B - Defining the class following with the keyword virtual C - Defining the class following with the keyword interface D - Defining the class following with the keyword abstract

A - By only providing all the functions as virtual functions in the class.

What is the output of the following program? #include<iostream> using namespace std; main() { int x = 5; if(x==5) { if(x==5) break; cout<<"Hello"; } cout<<"Hi"; } A - Compile error B - Hi C - HelloHi D - Hello

A - Compile error

Class function which is called automatically as soon as the object is created is called as __ A - Constructor B - Destructor C - Friend function D - Inline function.

A - Constructor

What is the output of the following program? #include<iostream> using namespace std; void f() { cout<<"Hello"<<endl; } main() { } A - No output B - Error, as the function is not called. C - Error, as the function is defined without its declaration D - Error, as the main() function is left empty

A - No output

What is the output of the following program? main() { } A - No output B - Garbage C - Compile error D - Runtime error

A - No output

i) Exception handling technically provides multi branching. ii) Exception handling can be mimicked using 'goto' construct. A - Only (i) is true B - Only (ii) is true C - Both (i) & (ii) are true D - Both (i) && (ii) are false

A - Only (i) is true

What is the full form of RTTI. A - Runtime type identification B - Runtime template identification C - Robust Template Type Inheritance D - None of the above.

A - Runtime type identification

What is the full form of STL? A - Standard template library. B - System template library. C - Standard topics library. D - None of the above.

A - Standard template library.

An inline function can execute faster than a normal function. A - True B - False

A - True

Q 24 - We can have varying number of arguments for the overloaded form of () operator. A - True B - False

A - True

From the below class choose the proper definition of the member function f(). template <class T> class abc { void f(); }; A - template <class T> void abc<T>::f() { } B - template<class T> void abc::f() { } C - template<T> void abc<class T>::f() { } D - template<T> void abc<T>::f() { }

A - template <class T> void abc<T>::f() { }

Escape sequence character '\0' occupies __ amount of memory. A - 0 B - 1 C - 2 D - 4

B - 1

What is the output of the following program? #include<iostream> using namespace std; main() { int a[] = {1, 2}, *p = a; out<<p[1]; } A - 1 B - 2 C - Compile error D - Runtime error

B - 2

What is the output of the following program? #include<iostream> using namespace std; void f() { static int i = 3; cout<<i; if(--i) f(); } main() { f(); } A - 3 2 1 0 B - 3 2 1 C - 3 3 3 D - Compile error

B - 3 2 1

What is the output of the following program? #include<iostream> using namespace std; class abc { void f(); void g(); int x; }; main() { cout<<sizeof(abc)<<endl; } A - 12 B - 4 C - 8 D - Compile error

B - 4

What is the output of the following program? #include<iostream> using namespace std; main() { int i = 13, j = 60; i^=j; j^=i; i^=j; cout<<i<<" "<<j; } A - 73 73 B - 60 13 C - 13 60 D - 60 60

B - 60 13

Abstract class is __ A - A class must contain all pure virtual functions B - A class must contain at least one pure virtual function C - A class may not contain pure virtual function. D - A class must contain pure virtual function defined outside the class.

B - A class must contain at least one pure virtual function

What is the output of the following program? #include<iostream> using namespace std; void main() { char *s = "C++"; cout<<s<<" "; s++; cout<<s<<" "; } A - C++ C++ B - C++ ++ C - ++ ++ D - Compile error

B - C++ ++

What is a generic class. A - Function template B - Class template B - Inherited class B - None of the above.

B - Class template

HAS-A relationship between the classes is shown through. A - Inheritance B - Container classes C - Polymorphism D - None of the above.

B - Container classes

What is the output of the following program? #include<iostream> using namespace std; class Base { public: virtual void f() { cout<<"Base\n"; } }; class Derived:public Base { public: void f() { cout<<"Derived\n"; } }; main() { Base *p = new Derived(); p->f(); } A - Base B - Derived C - Compile error D - None of the above.

B - Derived

With respective to streams >> (operator) is called as A - Insertion operator B - Extraction operator C - Right shift operator D - Left shift operator

B - Extraction operator

An array can be passed to the function with call by value mechanism. A - True B - False

B - False

In the following program f() is overloaded. void f(int x) { } void f(signed x) { } main() { } A - True B - False

B - False

In the following program f() is overloaded. void f(int x) { } int f(signed x){ return 1; } main() { } A - True B - False

B - False

We can use this pointer in static member function of the class. A - True B - False

B - False

What is the output of the following program? #include<iostream> using namespace std; class abc { public: int i; abc(int i) { i = i; } }; main() { abc m(5); cout<<m.i; } A - 5 B - Garbage C - Error at the statement i=i; D - Compile error: 'i' declared twice.

B - Garbage

Objects created using new operator are stored in __ memory. A - Cache B - Heap C - Stack D - None of the above.

B - Heap

What is the output of the following program? #include <iostream> using namespace std; int main () { // local variable declaration: int x = 1; switch(x) { case 1 : cout << "Hi!" << endl; break; default : cout << "Hello!" << endl; } } A - Hello B - Hi C - HelloHi D - Compile error

B - Hi

What is the output of the following program? #include<iostream> using namespace std; main() { char s[] = "Fine"; *s = 'N'; cout<<s<<endl; } A - Fine B - Nine C - Compile error D - Runtime error

B - Nine

'cin' is an __ A - Class B - Object C - Package D - Namespace

B - Object

Compiler generates ___ file A - Executable code B - Object code C - Assembly code D - None of the above.

B - Object code

i) Exceptions can be traced and controlled using conditional statements. ii) For critical exceptions compiler provides the handler A - Only (i) is true B - Only (ii) is true C - Both (i) & (ii) are true D - Both (i) && (ii) are false

B - Only (ii) is true

Does both the loops in the following programs prints the correct string length? #include<iostream> using namespace std; main() { int i; char s[] = "hello"; for(i=0; s[i]; ++i); cout<<i<<endl; i=0; while(s[i++]); cout<<i; } A - Yes, both the loops prints the correct length B - Only for loop prints the correct length C - Only while loop prints the correct length D - Compile error in the program.

B - Only for loop prints the correct length

A protected member of the class in accessible in A - Only same class B - Same class and derived class C - Outside the class D - None of the above.

B - Same class and derived class

Which type of data file is analogous to an audio cassette tape? A - Random access file B - Sequential access file C - Binary file D - Source code file

B - Sequential access file

Q 23 - Pick up the valid declaration for overloading ++ in postfix form where T is the class name. A - T operator++(); B - T operator++(int); C - T& operator++(); D - T& operator++(int);

B - T operator++(int);

Choose the invalid identifier from the below A - Int B - bool C - DOUBLE D - __0__

B - bool

Identify the C++ compiler of Linux A - cpp B - g++ C - Borland D - vc++

B - g++

What is the built in library function to compare two strings? A - string_cmp() B - strcmp() C - equals() D - str_compare()

B - strcmp()

The pointer which stores always the current active object address is __ A - auto_ptr B - this C - p D - none of the above.

B - this

What is the output of the following program? #include<iostream> using namespace std; main() { int a[] = {10, 20, 30}; cout<<*a+1; } A - 10 B - 20 C - 11 D - 21

C - 11

What is the output of the following program? #include<iostream> using namespace std; main() { int i = 1, j = 2, k = 3, r; r = (i, j, k); cout<<r<<endl; } A - 1 B - 2 C - 3 D - Compile Error

C - 3

What is the size of the following union definition? #include<iostream> using namespace std; main() { union abc { char a, b, c, d, e, f, g, h; int i; }; cout<<sizeof(abc); } A - 1 B - 2 C - 4 D - 8

C - 4

What is the output of the following program? #include<iostream> using namespace std; main() { union abc { int x; char ch; } var; var.ch = 'A'; cout<<var.x; } A - A B - Garbage value C - 65 D - 97

C - 65

Choose the option not applicable for the constructor. A - Cannot be called explicitly. B - Cannot be overloaded. C - Cannot be overridden. D - None of the above.

C - Cannot be overridden.

What is the output of the following program? #include<iostream> using namespace std; class Base { public: void f() { cout<<"Base\n"; } }; class Derived:public Base { public: void f() { cout<<"Derived\n"; }; }; main() { Derived obj; obj.Base::f(); } A - Base B - Derived C - Compile error D - None of the above.

C - Compile error

Which feature of the OOPS gives the concept of reusability? A - Abstraction B - Encapsulation C - Inheritance D - None of the above.

C - Inheritance

What is the output of the following program? #include<iostream> using namespace std; main() { char s[] = "hello", t[] = "hello"; if(s==t) cout<<"eqaul strings"; } A - Equal strings B - Unequal strings C - No output D - Compilation error

C - No output

i) single file can be opened by several streams simultaneously. ii) several files simultaneously can be opened by a single stream A - (i) and (ii) are true B - (i) and (ii) are false C - Only (i) is true D - Only (ii) is true

C - Only (i) is true

What is the output of the following program? #include<iostream> using namespace std; main() { int *p = new int; delete p; delete p; cout<<"Done"; } A - Done B - Compile error C - Runtime error D - None of the above

C - Runtime error

Runtime polymorphism is done using. A - Function overloading B - Virtual classes C - Virtual functions D - Friend function

C - Virtual functions

Special symbol permitted with in the identifier name. A - $ B - @ C - _ D - .

C - _

The default executable generation on UNIX for a C++ program is ___ A - a.exe B - a C - a.out D - out.a

C - a.out

Choose the respective delete operator usage for the expression 'ptr=new int[100]'. A - delete ptr; B - delete ptr[]; C - delete[] ptr; D - []delete ptr;

C - delete[] ptr;

Which of the following is not the keyword in C++? A - volatile B - friend C - extends D - this

C - extends

By default the members of the structure are A - private B - protected C - public D - Access specifiers not applicable for structures.

C - public

Q 20 - Which data type can be used to hold a wide character in C++? A - unsigned char; B - int C - wchar_t D - none of the above.

C - wchar_t

What is the output of the following program? #include<iostream> using namespace std; void f() { static int i; ++i; cout<<i<<" "; } main() { f(); f(); f(); } A - 1 1 1 B - 0 0 0 C - 3 2 1 D - 1 2 3

D - 1 2 3

What is the output of the following program? #include<iostream> using namespace std; int x = 5; int &f() { return x; } main() { f() = 10; cout<<x; } A - 5 B - Address of 'x' C - Compile error D - 10

D - 10

Which operator is used to resolve the scope of the global variable? A - −> B - . C - * D - ::

D - ::

Which operator is required to be overloaded as member function only? A - _ B - _ _ C - ++ (postfix version) D - =

D - =

Choose the Object oriented programming language from below. A - C++ B - Small talk C - Simula D - All the above.

D - All the above.

The copy constructor is executed on A - Assigned one object to another object at its creation B - When objects are sent to function using call by value mechanism C - When the function return an object D - All the above.

D - All the above.

Designer of C++ programming language. A - Charles Babbage B - Dennis Ritchie C - Brain Kernighan D - Bjarne Stroustrup

D - Bjarne Stroustrup

A C++ program statements can be commented using A - Single line comment B - Multi line comment C - Either (a) or (b) D - Both (a) and (b).

D - Both (a) and (b).

The programs machine instructions are store in __ memory segment. A - Data B - Stack C - Heap D - Code

D - Code

What is the output of the following program? #include<iostream> using namespace std; main() { class student { int rno = 10; } v; cout<<v.rno; } A - 10 B - Garbage C - Runtime error D - Compile error

D - Compile error

What is the output of the following program? #include<iostream> using namespace std; main() { const int a = 5; a++; cout<<a; } A - 5 B - 6 C - Runtime error D - Compile error

D - Compile error

What is the output of the following program? #include<iostream> using namespace std; main() { int r, x = 2; float y = 5; r = y%x; cout<<r; } A - 1 B - 0 C - 2 D - Compile error

D - Compile error

What is the output of the following program? #include<iostream> using namespace std; void main() { char s[] = "C++"; cout<<s<<" "; s++; cout<<s<<" "; } A - C++ C++ B - C++ ++ C - ++ ++ D - Compile error

D - Compile error

Q 25 - What is the size of 'int'? A - 2 B - 4 C - 8 D - Compiler dependent

D - Compiler dependent

What is the output of the following program? #include<iostream> using namespace std; main() { float t = 2; switch(t) { case 2: cout<<"Hi"; default: cout<<"Hello"; } } A - Hi B - HiHello C - Hello D - Error

D - Error

Choose the pure virtual function definition from the following. A - virtual void f()=0 { } B - void virtual f()=0 { } C - virtual void f() {} = 0; D - None of the above.

D - None of the above.

What is the output of the following program? #include<iostream> using namespace std; main() { char *s = "Fine"; *s = 'N'; cout<<s<<endl; } A - Fine B - Nine C - Compile error D - Runtime error

D - Runtime error

Which is the storage specifier used to modify the member variable even though the class object is a constant object? A - auto B - register C - static D - mutable

D - mutable

The following operator can be used to calculate the value of one number raised to another. A - ^ B - ** C - ^^ D -None of the above

D -None of the above

One of the following is true for an inline function. A - It executes faster as it is treated as a macro internally B - It executes faster because it priority is more than normal function C - It doesn't executes faster compared to a normal function D - None of the above holds true for an inline function

It executes faster as it is treated as a macro internally

C++ does not supports the following A - Multilevel inheritance B - Hierarchical inheritance C - Hybrid inheritance D - None of the above.

none of the above

The default access specifier for the class members is A - public B - private C - protected D - None of the above.

private


Related study sets

Ch 9 - Clinical Information Systems

View Set

Structural Kinesiology Chapter 5

View Set

2.02 B Student Handout (Business)

View Set

MedSurg 2 Exam 1 Study Set (ABG)

View Set