C++ Exam 2025 Created by admin C++ Exam 2025 1 / 31 Which of these is not a fundamental data type in C++? int float string char 2 / 31 What is the difference between delete and delete[] in C++? delete is syntactically correct but delete[] is wrong and hence will give an error if used in any case delete is used to delete normal objects whereas delete[] is used to pointer objects delete is a keyword whereas delete[] is an identifier delete is used to delete single object whereas delete[] is used to multiple(array/pointer of) objects 3 / 31 Which data type would be best to store a person's age? int double bool char 4 / 31 What happens if the following program is executed in C and C++? #include <stdio.h> int main(void) { int new = 5; printf("%d", new); } Error in C and successful execution in C++ Error in both C and C++ Error in C++ and successful execution in C A successful run in both C and C++ 5 / 31 Which of the following is used to terminate the function declaration in C++? ; ] ) : 6 / 31 Which is more effective while calling the C++ functions? call by object call by pointer call by value call by reference 7 / 31 What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { char c = 74; cout << c; return 0; } I J A N 8 / 31 Which of the following approach is used by C++? Left-right Right-left Bottom-up Top-down 9 / 31 What is abstract class in C++? Any Class in C++ is an abstract class Class from which any class is derived Class specifically used as a base class with atleast one virtual functions Class specifically used as a base class with atleast one pure virtual functions 10 / 31 Who invented C++? Dennis Ritchie Ken Thompson Brian Kernighan Bjarne Stroustrup 11 / 31 Which concept allows you to reuse the written code in C++? Inheritance Polymorphism Abstraction Encapsulation 12 / 31 What is the value of p in the following C++ code snippet? #include <iostream> using namespace std; int main() { int p; bool a = true; bool b = false; int x = 10; int y = 5; p = ((x | y) + (a + b)); cout << p; return 0; } 12 0 2 16 13 / 31 What will be the output of the following C++ code snippet? #include <iostream> using namespace std; int operate (int a, int b) { return (a * b); } float operate (float a, float b) { return (a / b); } int main() { int x = 5, y = 2; float n = 5.0, m = 2.0; cout << operate(x, y) <<"\t"; cout << operate (n, m); return 0; } 10.0 5 10 2.5 10.0 5.0 5.0 2.5 14 / 31 What will be the output of the following C++ code? #include<iostream> using namespace std; int main () { int cin; cin >> cin; cout << "cin: " << cin; return 0; } Segmentation fault Nothing is printed Error cin: garbage value 15 / 31 Which of the following correctly declares an array in C++? array{10}; array array[10]; int array; int array[10]; 16 / 31 Which of the following symbol is used to declare the preprocessor directives in C++? $ ^ # * 17 / 31 Which of the following is a correct identifier in C++? VAR_1234 $var_name 7VARNAME 7var_name 18 / 31 Which of the following is used for comments in C++? /* comment */ // comment */ // comment both // comment or /* comment */ 19 / 31 Which of the following type is provided by C++ but not C? double float int bool 20 / 31 What is a variable in C++? A constant value A data type A storage location with a name A keyword 21 / 31 The C++ code which causes abnormal termination/behaviour of a program should be written under _________ block. catch throw try finally 22 / 31 What is the use of the indentation in c++? r distinguishes between comments and inner data distinguishes between comments and outer data distinguishes between comments and code r distinguishes between comments and outer data 23 / 31 What is meant by a polymorphism in C++? class having only single form class having four forms class having many forms class having two forms 24 / 31 What is Inheritance in C++? Deriving new classes from existing classes Overloading of classes Classes with same names Wrapping of data into a single class 25 / 31 What will be the output of the following C++ code? #include <iostream> using namespace std; int main () { int a, b, c; a = 2; b = 7; c = (a > b) ? a : b; cout << c; return 0; } 12 14 6 7 26 / 31 What is C++? C++ is an object oriented programming language C++ is a procedural programming language C++ supports both procedural and object oriented programming language C++ is a functional programming language 27 / 31 What is the benefit of c++ input and output over c input and output? Both Type safety & Exception Sequence container Exception Type safety 28 / 31 What happens if the following program is executed in C and C++? #include <stdio.h> void func(void) { printf("Hello"); } void main() { func(); func(2); } Outputs Hello twice in both C and C++ Error in C and successful execution in C++ Error in C++ and successful execution in C Error in both C and C++ 29 / 31 Which of the following constructors are provided by the C++ compiler if not defined in a class? Copy constructor Default constructor Copy Assignment Operator All of the mentioned 30 / 31 What distinguishes a class from an object in OOP? A class is a blueprint, while an object is an instance of a class A class cannot contain methods, while an object can Objects are templates, while classes are real entities There is no difference 31 / 31 Which of the following is the correct syntax of including a user defined header files in C++? #include [userdefined] #include “userdefined” #include #include LinkedIn Facebook 0%