Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Home » List of Companies » IBM Technical Questions

IBM C++ Interview Questions

These 41 C++ were taken from IBM C++ Online Test conducted recently in 2020. Questions covers most of the topics from C++. -

Question 1 of 41:
Which of the following is a function that must be part of every C++ program
A. main()
B. iostream()
C. printf()
D. begin()

Question 2 of 41:
Keyword hold specific meaning to a language compiler and these words cannot be used for any other purpose in the program. Which of the following is NOT a C__ keyword?
A. if
B. bool
C. sizeof
D. thereof
E. class

Questions 3 of 41:
Which of the following is the correct syntax for the iostream.h include header file?
A. include iostream.h
B. include
C. #include "iostream.h"
D. #include

Question 4 of 41:
The C++ preprocessor runs before the compiler starts compiling. Which of the following is a preprocessor directive?
A. #include
B. #define
C. #ifdef
D. #endif
E. All the above

Question 5 of 41:
Which of the following statements coforms to C++ statement syntax?
A. cout<<"Hello World";
B. double x=25.6;
C. i=i++;
D. All of the above

Question 6 of 41:
Which of the following is a C++ data type?
A. bool
B. float
C. null
D. A & B
E. All of the above

Question 7 of 41:
Which of the following statements will output the size of variable "X"?
A. cout<<"x is"<<sizeof(x);
B. cout<<"x is"==SizeOf(X);
C. cout<<"x is"<<sizeof(X);
D. cout<<"x is"!=sizeof(X);

Question 8 of 41:
Which of the following statements about class inheritance in C++ is TRUE?
A. A class can be inherited from a class that itself is inherited from another class.
B. The functions and variable of a base class become part of the inherited class.
C. There is not limit on classes that can be inherited from a single class.
D. All of the above

Question 9 of 41:
Which of the following will inherit a class called "honda" from a base class called "car"?
A. class honda: public car
B. class honda:public car
C. class car : public honda
D. class car :: public honda

Question 10 of 41:
Which of the following statement about a block is TRUE?
A. A variable declared in a block is available
B. Blocks can be nested within other blocks
C. A variable declared in a block is available to all the block in the same function.
D. A & B
E. All of the above

Question 11 of 41:
Which of the following keyword is used to define a aggregate data type?
A. struct
B. class
C. function
D. subroutine

Question 12 of 41:
Which of the following will declare an array in C++?
A. int students[20];
B. int students(20);
C. struct students[20];
D. struct student(20);

Question 13 of 41:
Which of the following statements will declare a pointer "pntr" and assign an address of variable "var"?
A. int &pntr = *var;
B. int* pntr = &var;
C. int pntr[] =var;
D. struct *pntr = [var];

Question 14 of 41:
Which of the following C++ keywords is used to allocate dynamic memory?
A. allocate
B. create
C. new
D. dynamic

Question 15 of 41:
Bitwise operators are useful in applications where memory usage needs to be kept at a minimum. Which of the following operators is used to perform the bitwise "AND" operations?
A. &
B. <<
C. >>
D. |
E. ^

Question 16 of 41:
Which of the following loop types is supported by C++? A. for loop
B. do..whileloop
C. while loop
D. A & B
E. All of the above

Question 17 of 41:
Which of the following statements is used to stop a loop before the required condition is met?
A. close
B. switch
C. break
D. return

Question 18 of 41:
Which of the following will pass arguments to function parameters in C++?
A. By Value
B. By References
C. By Address
D. A & C
E. All of the above

Question 19 of 41:
Which of the following statement will declare a function that will NOT return any value to a calling program?
A. int employee(name, age, address);
B. void employee(name, age, address);
C. NULL employee(name, age, address);
D. float employee(name, age, address);

Question 20 of 41:
Which of following statement about class members is TRUE?
A. By default, class members can only be used within the class.
B. Members must be declared as public to be used outside a class.
C. Members must be declared as global to be used outside a class.
D. A & B
E. All of the above

Question 21 of 41:
In C++, it is possible to define multiple functions with the same name. The process of doing so is referred to as which of the following?
A. function downloading
B. function duplication
C. function overloading
D. multiple function

Question 22 of 41:
Heap is a portion of memory that is set aside for a program to dynamically allocate memory. Which of the following is a C++ operator used to dynamically assign memory?
A. allocate
B. new
C. <<
D. sizeof

Question 23 of 41:
Which of the following will dynamically allocate an integer array?
A. int empno = * new int[10];
B. int new empno = new int[10];
C. int empno = new int[10];
D. int *empno = new int[10];

Question 24 of 41:
Large development projects typically consist of multiple program files. If you would like to use a variable defined in another file, which of the following commands should you use?
A. global
B. new
C. extern
D. file

Question 25 of 41:
Which of the following is a C++ operator that takes three operands?
A. <<
B. <
C. ?:
D. ++

Question 26 of 41:
Consider two numbers num1 and num2. Which of the following will display the larger the two numbers?
A. cout<<((num1 > num2)? num1: num2);
B. cout<<((num2 > num1)? num1: numb2);
C. cout<<((num1 > num2)? num1::num2);
D. cout<<<((num2 > num1)? num1::num2);

Question 27 of 41:
Which of the following statements about function overloading is TRUE? A. The function name is the same, but the parameters should have different data types.
B. The function that is called depends on the parameters
C. Overloaded function can return values of different types
D. A & B
E. All of the above

Question 28 of 41:
Which of the following indicates the result of the code below?
int num1=5; int num2=num1++;
A. num1=5 and num2=6
B. num1=5 and num2=5
C. num1=6 and num2=5
D. num1=6 and num2=6

Question 29 of 41:
Which of the following will delete a dynamically allocated array called "CarArray"?
A. Unallocated[] CarArray;
B. delete CarArray;
C. delete[] CarArray;
D. Unallocate CarArray;

Question 30 of 41:
Given the code below, which of the following statements will append the string "Accord" to sCar?
A. sCar += string("Accord");
B. sCar.append("Accord");
C. sCar.Append("Accord");
D. A and B
E. All of the above

Question 31 of 41:
Which of the following will include a header file for using string functionality in C++ program?
A. #include;
B. #include:
C. #include;
D. All of the above

Question 32 of 41:
In C++, it is possible for the child class to inherit functionality from more than one parent class.
A. True
B. False

Question 33 of 41:
Which of the following is NOT a C++ relation operator?
A. !=
B. ==
C. <
D. >=
E. ::

Question 34 of 41:
Which of the following file I/O classes is used perform both file input and file output?
A. ifstream
B. ofstream
C. fstream
D. iostream

Question 35 of 41:
Which of the following C++ classes is used for opening a file as read-only?
A. ofstream
B. ifstream
C. fstream
D. iostream

Question 36 of 41:
Which of the following statements about enumerated data types in C++ is TRUE?
A. It is declared using the enum operator.
B. It is very useful for writing readable code.
C. The symbolic constants are only assigned integer vlaues.
D. A & B
E. All of the above

Question 37 of 41:
Which of the following is a C++ function that manipulates null terminated strings?
A. strlen
B. strcpy
C. strcompare
D. A & B
E. B & C

Question 38 of 41:
A. ::
B. >=
C. <<
D. |

Question 39 of 41:
Which of the C++ statements will throw exception in C++?
A. catch "exception occured";
B. try "exception occured";
C throw "exception occured";
D. exception "exception occured";

Question 40 of 41:
Which of the following interupts can be handled in C++?
A. SIGABRT
B. SIGFPE
C. SIGSEGV
D. A & B
E. All of the above

Question 41 of 41:
Which of the following C++ keywords is used to trap or catch interupts in C++?
A. trap
B. singal
C. catch
D. raise