- What is the output of the following C++ code?
C++
int x = 10;
cout << (x++ + ++x);
A) 21
B) 22
C) Undefined behavior ✅
D) 20 - Which of the following correctly defines a reference variable in C++?
A) int *ref = a;
B) int &ref = a; ✅
C) ref int = a;
D) int ref = &a; - Which function is used to compare two strings in C?
A) strcompare()
B) strcmp() ✅
C) compare()
D) strcomp() - Which keyword is used to prevent a function from being overridden?
A) static
B) const
C) final ✅
D) virtual - What does NULL represent?
A) 1
B) 0 or no address ✅
C) -1
D) Garbage value - Which of the following is a correct destructor declaration?
A) className() ✅
B) destructor()
C) className()
D) delete() - Which operator is overloaded by default in C++?
A) +
B) = ✅
C) *
D) / - What is multiple inheritance?
A) One class inherits from one class
B) One class inherits from multiple classes ✅
C) Multiple classes inherit from one class
D) None - Which keyword is used to declare constant pointer?
A) const int *p
B) int *const p ✅
C) constant pointer
D) static pointer - Which function is used to release memory in C++?
A) free()
B) release()
C) delete ✅
D) remove() - What is the purpose of this pointer?
A) Points to class
B) Points to current object ✅
C) Points to function
D) Points to memory - Which header file is used for string functions?
A) stdlib.h
B) string.h ✅
C) stdio.h
D) math.h - Which keyword is used to define macro?
A) macro
B) define
C) #define ✅
D) #macro - What is the output of:
C
printf(“%d”, 5/2);
A) 2 ✅
B) 2.5
C) 3
D) Error - Which of the following is not a type of inheritance?
A) Single
B) Multiple
C) Hybrid
D) Parallel ✅ - What is a pure virtual function?
A) Virtual function without body ✅
B) Inline function
C) Static function
D) Private function - Which keyword is used for exception throwing?
A) catch
B) try
C) throw ✅
D) error - Which symbol is used for logical AND?
A) &
B) && ✅
C) ||
D) ! - What is function template?
A) Generic function ✅
B) Recursive function
C) Inline function
D) Virtual function - Which loop is best when number of iterations is known?
A) while
B) do-while
C) for ✅
D) none - What is memory leak?
A) Memory overflow
B) Unreleased allocated memory ✅
C) Null pointer
D) Buffer overflow - Which operator is used for bitwise AND?
A) &&
B) & ✅
C) ||
D) ^ - What is the output of:
C
int a=5;
printf(“%d”, a<<1);
A) 5
B) 10 ✅
C) 2
D) 20 - Which keyword is used for inheritance access control?
A) public ✅
B) class
C) friend
D) new - What is call by reference?
A) Passing value
B) Passing address/reference ✅
C) Passing pointer
D) Passing function - Which operator is used for ternary condition?
A) :
B) ? : ✅
C) ::
D) -> - What is stack memory used for?
A) Dynamic allocation
B) Static allocation
C) Function calls and local variables ✅
D) Global variables - Which keyword is used for default function arguments?
A) default ✅
B) auto
C) const
D) static - What is the output of:
C
printf(“%d”, sizeof(float));
A) 2
B) 4 ✅
C) 8
D) 16 - Which function is used to open file in C?
A) open()
B) fopen() ✅
C) fileopen()
D) create() - Which operator is used for bitwise OR?
A) ||
B) | ✅
C) &
D) ^ - What is inline function?
A) Function inside class
B) Function expanded at compile time ✅
C) Runtime function
D) Recursive function - Which keyword is used to define structure in C?
A) class
B) struct ✅
C) union
D) typedef - Which of the following is correct file closing function?
A) close()
B) fclose() ✅
C) fileclose()
D) endfile() - What is operator precedence?
A) Operator priority ✅
B) Loop
C) Function
D) Pointer - Which keyword is used for pointer to constant?
A) const int *p ✅
B) int *const p
C) constant pointer
D) pointer const - What is buffer overflow?
A) Memory leak
B) Exceeding buffer limit ✅
C) Pointer error
D) Syntax error - Which keyword is used for virtual inheritance?
A) virtual ✅
B) static
C) final
D) friend - Which function reads character from file?
A) getchar()
B) fgetc() ✅
C) getcfile()
D) read() - What is segmentation fault?
A) Compilation error
B) Runtime memory access violation ✅
C) Syntax error
D) Linker error - Which operator is used for bitwise XOR?
A) ^ ✅
B) &
C) |
D) ~ - What is class template?
A) Generic class ✅
B) Static class
C) Virtual class
D) Abstract class - Which keyword is used to create object?
A) new
B) class
C) object
D) None (objects are declared normally) ✅ - Which is not a valid loop control statement?
A) break
B) continue
C) exit
D) return ✅ - What is the output of:
C
printf(“%d”, 3*2+4);
A) 10 ✅
B) 14
C) 12
D) 8 - Which keyword is used for file scope variable?
A) extern ✅
B) static
C) auto
D) register - What is copy constructor?
A) Constructor with no arguments
B) Constructor with same class reference ✅
C) Destructor
D) Default constructor - Which operator is used to allocate memory in array dynamically in C++?
A) malloc
B) new[] ✅
C) alloc
D) array() - Which is not a feature of C++?
A) OOP
B) Platform dependent
C) Garbage collection ✅
D) Strong typing - What is abstraction in C++?
A) Showing only essential features ✅
B) Looping
C) Memory allocation
D) Pointer
Pages: 1 2