C ++ Final Online Exam

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By SPACECOMPUTER
S
SPACECOMPUTER
Community Contributor
Quizzes Created: 10 | Total Attempts: 56,607
| Attempts: 287 | Questions: 50
Please wait...
Question 1 / 50
0 %
0/100
Score 0/100
1. What punctuation must each command line have at the end of the line ?

Explanation

Each command line must have a semicolon (;) at the end of the line. This punctuation is used to indicate the end of a command or statement in many programming languages. It is necessary to separate multiple commands or statements on the same line or to terminate a single command or statement. The other punctuation marks listed (colon, comma, and exclamation mark) do not serve this purpose and are not typically used at the end of a command line.

Submit
Please wait...
About This Quiz
C ++ Final Online Exam - Quiz

With every final exam there is no doubt that some people will be unsure about their readiness to sit for it and getting some accurate quizzes to help you can give you the grade you want. Take up the C++ final online exam below and see how you would have... see morescored. see less

Personalize your quiz and earn a certificate with your name on it!
2. What does the statement #include do ?

Explanation

The statement #include is used in C++ programming to include a library or header file in the program. In this case, the statement #include defines the function iostream.h, which is a header file that contains the declarations needed for input and output operations in C++. This allows the program to use functions like cout and cin for input and output.

Submit
3.  Can constructors be overloaded?

Explanation

Constructors can be overloaded in object-oriented programming languages. Overloading a constructor means having multiple constructors with different parameter lists within the same class. This allows creating objects using different sets of arguments, providing flexibility and customization. Overloaded constructors can have different numbers or types of parameters, enabling the creation of objects with different initial states. Therefore, the correct answer is yes.

Submit
4.  In the C Language 'A' represents ________________.

Explanation

In the C Language, 'A' represents a character. In C, characters are enclosed in single quotes, and 'A' specifically represents the character 'A'. Characters in C are used to represent individual letters, digits, or special symbols. In this case, 'A' is a character and not a digit or an integer.

Submit
5. The break key word allows you to jump out of any loop at any time.

Explanation

The break keyword is used in programming to exit out of a loop prematurely. It allows you to jump out of the loop at any time, regardless of the loop condition. This can be useful when you want to stop the execution of a loop based on a certain condition being met. Therefore, the statement that the break keyword allows you to jump out of any loop at any time is true.

Submit
6. When you are creating a structure, you need to use the following keyword

Explanation

When creating a structure, the correct keyword to use is "struct". This keyword is used to define a structure in programming languages such as C or C++. It is followed by the structure name and a set of braces to define the members of the structure. The "struct" keyword indicates that we are creating a new structure type.

Submit
7. Single line comments explaining code would be preceded like in the following example

Explanation

not-available-via-ai

Submit
8. Every class has at least one constructor function, even when none is declared.

Explanation

In object-oriented programming, a constructor is a special method that is called when an object is created. It is responsible for initializing the object's state. In most programming languages, if a class does not explicitly declare a constructor, a default constructor is automatically provided. This default constructor takes no arguments and performs no initialization. Therefore, every class has at least one constructor function, even when none is declared. This ensures that objects of the class can be created and initialized properly.

Submit
9. The maximum value that an integer constant can have is ____________________.

Explanation

The maximum value that an integer constant can have is 3276700%.

Submit
10. The C++ language is

Explanation

The correct answer is "case-sensitive" because in C++ language, the uppercase and lowercase letters are treated as distinct and separate. This means that variables, functions, and keywords must be written with the exact same casing when used in different parts of the code. For example, "variable1" and "Variable1" would be considered two different variables in C++. Therefore, it is important to be consistent with the casing of identifiers in order for the code to compile and execute correctly.

Submit
11. To find factorial of A by using while loop,  A will be ________________.

Explanation

The correct answer is A>0 because in order to find the factorial of a number using a while loop, we need to iterate the loop until the number becomes 0. So, A should be greater than 0 to enter the loop and perform the factorial calculation.

Submit
12. A do while loop is very similar to a while loop.

Explanation

A do while loop is similar to a while loop because both are used for repetitive execution of a block of code based on a condition. However, the main difference is that a do while loop always executes the code block at least once, regardless of whether the condition is initially true or false. In contrast, a while loop may not execute the code block at all if the condition is initially false. Therefore, the statement that a do while loop is very similar to a while loop is true.

Submit
13. What is the difference between overloaded functions and overridden functions?

Explanation

Overloading and overriding are both concepts used in object-oriented programming to define multiple versions of a function. The main difference between them lies in the binding time. Overloading is a dynamic or run-time binding, which means that the decision of which function to call is made during the execution of the program. On the other hand, overriding is a static or compile-time binding, where the decision of which function to call is made at compile-time based on the type of the object. Therefore, the correct answer states that overloading is dynamic or run-time binding, while overriding is static or compile-time binding.

Submit
14. The default access level assigned to members of a class is ___________

Explanation

The default access level assigned to members of a class is private. This means that the members can only be accessed within the class itself and are not accessible from outside the class.

Submit
15. C++ provides facility to specify that the compiler should match function calls with the correct definition at the run time. This process is called as

Explanation

Dynamic Binding is the correct answer because in C++, the compiler can match function calls with the correct definition at runtime. This means that the specific function to be executed is determined based on the actual type of the object being referenced or pointed to, rather than the static type of the reference or pointer. This allows for polymorphism and enables the program to choose the appropriate function implementation based on the object's type at runtime.

Submit
16. Macros are defined using ___________________ statement.

Explanation

Macros are defined using the "#define" statement. This statement is used to define a macro in C and C++ programming languages. It allows developers to define a name or identifier as a replacement for a particular value or code snippet. This helps in simplifying code, improving readability, and making it easier to maintain and modify. The "#define" statement is followed by the macro name and its corresponding value or code.

Submit
17. To include code from the library in the program, such as iostream, a directive would be called up using this command.

Explanation

The correct answer is #include . This is the correct way to include the iostream library in a C++ program. The other options either have incorrect syntax or use an outdated version of including the iostream library.

Submit
18.  ____________________ of the following is allowed in a C arithmetic instruction. 

Explanation

The parentheses () are allowed in a C arithmetic instruction. Parentheses are used to specify the order of operations in an arithmetic expression, allowing certain operations to be performed before others. They are used to group subexpressions and control the evaluation order of the arithmetic expression.

Submit
19. Which line has all reserved words ?

Explanation

The line "if, else, for, while do, switch, continue, break" has all reserved words. These words are keywords in programming languages that have a predefined meaning and cannot be used as variable names or identifiers. They are used to define control structures and flow of execution in a program.

Submit
20. What is the Difference between struct and class in terms of Access Modifier?

Explanation

not-available-via-ai

Submit
21.  ________________ are the ASCII values for number 0-9.

Explanation

The ASCII values for numbers 0-9 range from 48 to 57.

Submit
22. There is nothing like a virtual constructor of a class.

Explanation

The statement "There is nothing like a virtual constructor of a class" is true. In object-oriented programming, a constructor is a special member function that is automatically called when an object is created. However, constructors cannot be declared as virtual in most programming languages. Virtual functions can be overridden by derived classes, but constructors cannot be inherited or overridden. Therefore, there is no concept of a virtual constructor in a class.

Submit
23. The goto statement causes control to go to ___________________.

Explanation

The goto statement causes control to go to a specific location in the code, which is identified by a label. This allows the programmer to jump to a different part of the program, bypassing the normal flow of execution. Using a label as the target of a goto statement can be useful in certain situations, such as breaking out of nested loops or implementing error handling.

Submit
24. The goto statement causes control to go to ___________________.

Explanation

The goto statement causes control to go to a specific labeled statement within the program. It allows for non-sequential execution of code by transferring control to a different part of the program. This can be useful in certain situations, such as when implementing error handling or creating loops with complex conditions. The "And" option is incorrect because the goto statement does not perform logical operations, but rather controls the flow of execution within the program.

Submit
25. Cout can print multiple values or variables in a single command using the following syntax:

Explanation

not-available-via-ai

Submit
26. An abstract class can be instantiated.

Explanation

An abstract class cannot be directly instantiated, meaning we cannot create objects of an abstract class using the "new" keyword. However, we can create objects of a subclass that extends the abstract class. In other words, an abstract class can be used as a blueprint for creating objects of its subclasses. Therefore, the statement "An abstract class can be instantiated" is true.

Submit
27. C Language came into existence in the year ____________________. 

Explanation

C Language came into existence in the year 1972.

Submit
28. The Symbol && is read as ____________________.

Explanation

The symbol && is read as "and" in programming languages such as C, C++, Java, and JavaScript. It is used to combine two conditions in a logical statement, where both conditions must be true for the overall expression to be true.

Submit
29. The number 5.9875e17 must be stored in a(n):

Explanation

The number 5.9875e17 is a very large number, which cannot be accurately represented by an int or a long data type. Both int and long data types have a limited range and cannot store such a large value. On the other hand, a double data type can store large floating-point numbers with a high precision. Therefore, the number 5.9875e17 must be stored in a double data type.

Submit
30. Write a for loop that counts from 0 to 5.

Explanation

The correct answer is "for (c = 0; c

Submit
31. Which of the following library function below by default aborts the program?

Explanation

The exit() function by default aborts the program. This function is used to terminate the program and return a value to the operating system. When the exit() function is called, it immediately ends the program execution and any remaining code after the exit() function call will not be executed.

Submit
32. Which of the following below is /are a valid iterator type?

Explanation

Both a and c above are valid iterator types.

An input iterator is used to read values from a sequence and can only be moved forward. It allows multiple passes over the same sequence.

A forward iterator is similar to an input iterator but also allows modification of the values in the sequence.

Therefore, both input iterator (a) and forward iterator (c) are valid iterator types. Backward iterator is not a valid iterator type.

Submit
33. Inline functions are invoked at the time of

Explanation

Inline functions are invoked at compile time because they are expanded by the compiler directly into the calling code. This means that there is no function call overhead at runtime, as the code of the inline function is inserted directly into the calling code. Therefore, the invocation of inline functions happens during the compilation process rather than at runtime.

Submit
34. For which values of the integer _value will the following code become an infinite loop? int number=1; while (true) { cout << number; if (number == 3) break; number += _value; }

Explanation

In this code, the while loop will continue indefinitely until the condition "number == 3" is met. The variable "number" starts at 1 and increments by the value of "_value" each time through the loop. The only way for the loop to become an infinite loop is if "_value" is set to 1. This is because when "_value" is 1, "number" will continuously increment by 1 and will never equal 3, causing the loop to run indefinitely. Therefore, the code will only become an infinite loop when "_value" is set to 1.

Submit
35. Select the correct function definition (NOT prototype) from the list below.

Explanation

The correct function definition is "double pow(double num, int pow);" because it follows the correct syntax for defining a function. It specifies the return type "double" followed by the function name "pow". It also includes the required parameters inside the parentheses, with the first parameter being of type "double" and named "num", and the second parameter being of type "int" and named "pow".

Submit
36. Select the correct definition for a string variable.

Explanation

The correct definition for a string variable is "char mystr[20];". This is because it declares a variable named "mystr" as a character array with a size of 20. In C or C++ programming, a string is represented as an array of characters terminated by a null character. Therefore, using a character array is the appropriate way to define a string variable. The other options are incorrect because they either declare a variable as a string object or an array of string objects, which is not the correct way to define a string variable in this context.

Submit
37. The sentence "Hello world!" uses _____ elements in a character array.

Explanation

The sentence "Hello world!" uses 13 elements in a character array because it consists of 12 characters (including the space) and an additional element for the null character '\0' that marks the end of the string.

Submit
38. Which of the following converts an integer "value" to its ASCII equivalent ?

Explanation

The function atoi() converts a string representation of an integer to its corresponding integer value. It does not convert an integer value to its ASCII equivalent. Therefore, the given answer is incorrect.

Submit
39. Which classes allow primitive types to be accessed as objects?

Explanation

Wrapper classes in Java allow primitive types to be accessed as objects. These classes provide a way to wrap primitive data types (such as int, float, boolean, etc.) into an object so that they can be used in situations where objects are required. The wrapper classes provide various utility methods for converting between primitive types and their corresponding wrapper objects, as well as performing operations on them. This allows for more flexibility and functionality when working with primitive types in Java.

Submit
40.  How do we define a destructor?

Explanation

A destructor is defined using the syntax ~X() {}. In this case, the correct answer is X() ~{}. This syntax indicates that the function X() is the destructor for the class X. The destructor is responsible for cleaning up any resources that the object may have acquired during its lifetime, such as closing files or deallocating memory.

Submit
41. What happens when a pointer is deleted twice?

Explanation

Deleting a pointer twice can cause a trap. When a pointer is deleted, the memory it points to is deallocated. However, if the same pointer is deleted again, it attempts to deallocate the same memory location that has already been deallocated. This leads to undefined behavior, which can manifest as a trap. A trap is an exception or error that interrupts the normal execution of a program, causing it to terminate abruptly.

Submit
42. Which of the following below can perform conversions between pointers to related classes?

Explanation

Static_cast is a type of casting operator in C++ that can perform conversions between pointers to related classes. It is used to convert pointers or references from one type to another, as long as there is a valid conversion path between the types. Unlike dynamic_cast, static_cast does not perform any runtime type checking and does not require the use of virtual functions. It is mainly used for safe and explicit type conversions, such as converting a base class pointer to a derived class pointer.

Submit
43. What is deep copy?

Explanation

A deep copy creates a copy of the dynamically allocated objects too. This means that not only the values of the data are copied, but also any objects that have been created dynamically using memory allocation. This ensures that the copied object is completely independent and separate from the original object, including any dynamically allocated memory. This is in contrast to a shallow copy, which only copies the references to dynamically allocated objects, resulting in multiple objects pointing to the same memory location.

Submit
44. What defines a general set of operations that will be applied to various types of data?

Explanation

A function template is a general set of operations that can be applied to various types of data. It allows the user to define a generic function that can be used with different data types, without having to write separate functions for each type. By using a function template, the user can write a single function definition that can be used with different data types, making the code more flexible and reusable. So, the correct answer is function template.

Submit
45. What is the output of the following code? for (int a = 1; a <= 1; a++) cout << a++; cout << a;

Explanation

The code starts with a = 1 and enters the for loop. Inside the loop, the value of a is printed (which is 1) and then incremented by 1. The loop condition is checked again, but since a is now 2, the loop exits. Finally, the value of a (which is 2) is printed. Therefore, the output is 22.

Submit
46. Vtables

Explanation

Vtables, also known as virtual function tables, are used in object-oriented programming to implement polymorphism. They are used to resolve function calls at runtime when dealing with inheritance and virtual functions.

The correct answer is "creates a static table per class" because vtables are created per class, not per object. Each class that has virtual functions will have its own vtable, which is a static table that contains pointers to the virtual functions of that class. This table is shared by all objects of that class and is used to determine which function to call when a virtual function is invoked.

Submit
47. Which one of the choices would produce the following output ?

Explanation

not-available-via-ai

Submit
48. What is the output of the following code? for (int i=0; i<10; i++); cout << i%2 << " "; }

Explanation

The code is using a for loop to iterate from 0 to 9. After each iteration, it is printing the value of i%2 followed by a space. Since i is incremented by 1 after each iteration, i%2 will alternate between 0 and 1. Therefore, the output will be 1 0 1 0 1 0 1 0 1 0.

Submit
49. What function initalizes variables in a class:

Explanation

The correct answer is "A and B are". In object-oriented programming, a constructor is a special type of method that is used to initialize the variables of a class when an object is created. On the other hand, a destructor is a method that is called when an object is destroyed or goes out of scope. Both the constructor and destructor are used to manage the lifecycle of an object and perform necessary initialization and cleanup tasks. Therefore, both A (constructor) and B (destructor) are responsible for initializing variables in a class.

Submit
50. What is shallow copy?

Explanation

A shallow copy refers to creating a copy of an object where the values of the data are simply copied as they are. In addition to copying the values, a shallow copy also creates copies of both dynamically allocated objects and statically allocated objects. Therefore, the correct answer is both option b and c above.

Submit
View My Results

Quiz Review Timeline (Updated): Feb 17, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Feb 17, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jul 05, 2012
    Quiz Created by
    SPACECOMPUTER
Cancel
  • All
    All (50)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What punctuation must each command line have at the end of the line ?
What does the statement #include do ?
 Can constructors be overloaded?
 In the C Language 'A' represents ________________.
The break key word allows you to jump out of any loop at any time.
When you are creating a structure, you need to use the following...
Single line comments explaining code would be preceded like in the...
Every class has at least one constructor function, even when none is...
The maximum value that an integer constant can have is...
The C++ language is
To find factorial of A by using while loop,  A will be...
A do while loop is very similar to a while loop.
What is the difference between overloaded functions and overridden...
The default access level assigned to members of a class is ___________
C++ provides facility to specify that the compiler should match...
Macros are defined using ___________________ statement.
To include code from the library in the program, such as iostream, a...
 ____________________ of the following is allowed in a C...
Which line has all reserved words ?
What is the Difference between struct and class in terms of Access...
 ________________ are the ASCII values for number 0-9.
There is nothing like a virtual constructor of a class.
The goto statement causes control to go to ___________________.
The goto statement causes control to go to ___________________.
Cout can print multiple values or variables in a single command using...
An abstract class can be instantiated.
C Language came into existence in the year ____________________. 
The Symbol && is read as ____________________.
The number 5.9875e17 must be stored in a(n):
Write a for loop that counts from 0 to 5.
Which of the following library function below by default aborts the...
Which of the following below is /are a valid iterator type?
Inline functions are invoked at the time of
For which values of the integer _value will the following code become...
Select the correct function definition (NOT prototype) from the list...
Select the correct definition for a string variable.
The sentence "Hello world!" uses _____ elements in a...
Which of the following converts an integer "value" to its...
Which classes allow primitive types to be accessed as objects?
 How do we define a destructor?
What happens when a pointer is deleted twice?
Which of the following below can perform conversions between pointers...
What is deep copy?
What defines a general set of operations that will be applied to...
What is the output of the following code?...
Vtables
Which one of the choices would produce the following output ?
What is the output of the following code?...
What function initalizes variables in a class:
What is shallow copy?
Alert!

Advertisement