1.
The notation of logical NOT operator in a C++ program is
Correct Answer
D. !
Explanation
The correct answer is "!". In C++, the "!" symbol is used as the logical NOT operator. It is a unary operator that negates the truth value of its operand.
2.
For the class exforsys defined as below: class exforsys { }; int main() { exforsys a; } Which of the following is TRUE?
Correct Answer
B. The compiler provides the default constructor
Explanation
The given code defines a class called exforsys and creates an object of this class named 'a' in the main function. Since no constructor is explicitly defined in the class, the compiler automatically provides a default constructor. Therefore, the correct answer is "The compiler provides the default constructor."
3.
The notation of ternary operator is
Correct Answer
B. ?:
Explanation
The notation of the ternary operator is "?:". This operator is a shorthand way of writing an if-else statement. It takes three operands - a condition, a value to be returned if the condition is true, and a value to be returned if the condition is false. The operator evaluates the condition, and if it is true, it returns the first value; otherwise, it returns the second value.
4.
When the object of the first class is instantiated then which of the following is called?
Correct Answer
B. Constructor
Explanation
When the object of the first class is instantiated, the constructor is called. The constructor is a special member function of a class that is automatically called when an object of that class is created. It is used to initialize the object's data members and perform any necessary setup operations. In this case, since the object of the first class is being created, the constructor of that class will be called.
5.
Which of the following denotes the C++ looping statement?
Correct Answer
C. Both A and B
Explanation
Both the do-while and for statements are looping statements in C++. The do-while statement executes a block of code at least once, and then repeatedly executes it as long as a certain condition is true. The for statement is used to execute a block of code repeatedly for a fixed number of times. Therefore, both options A (do-while) and B (for) are correct answers for this question.
6.
Which of the following can be used to initialize a newly declared variable from an existing variable?
Correct Answer
C. Copy constructor
Explanation
A copy constructor can be used to initialize a newly declared variable from an existing variable. This constructor creates a new object by copying the values of another object of the same class. It is used when we want to create a new object that is a copy of an existing object. By using a copy constructor, we can ensure that the new object has the same values as the existing object, avoiding any potential issues with shallow copying or pointer manipulation.
7.
A template can be instantiated by
Correct Answer
C. Both A and B
Explanation
A template can be instantiated by both explicit instantiation and implicit instantiation. Explicit instantiation occurs when the template is explicitly instantiated by the programmer using the template arguments. Implicit instantiation, on the other hand, happens automatically when the template is used with specific arguments in the code. Therefore, both A (explicit instantiation) and B (implicit instantiation) are valid ways to instantiate a template.
8.
The minimum number of times a do loop would definitely get executed is:
Correct Answer
B. 1
Explanation
A do loop will definitely get executed at least once because the condition for exiting the loop is checked at the end of each iteration. Therefore, even if the condition is initially false, the loop will still execute once before checking the condition again.
9.
Strict parameter type checking is followed by which of these?
Correct Answer
A. Inline
Explanation
Inline is the correct answer because strict parameter type checking is followed by inline functions. Inline functions are a way to optimize code execution by inserting the function's code directly into the calling code, eliminating the overhead of function calls. Since the code is inserted directly, it allows for strict type checking of the parameters at compile time, ensuring that the correct types are used. Macros, on the other hand, are not subject to strict type checking as they are expanded by the preprocessor before compilation.
10.
The variables that can be used only within the function in which it is declared is called as
Correct Answer
B. Local Variables
Explanation
Local variables are variables that are declared within a specific function and can only be accessed and used within that function. They have a limited scope and are not accessible outside of the function. Global variables, on the other hand, can be accessed and used from any part of the program. Therefore, the correct answer is local variables.
11.
How many values can be returned by a C++ function?
Correct Answer
A. 1
Explanation
A C++ function can return only one value. Unlike other programming languages, C++ does not support multiple return values from a function. Therefore, the correct answer is 1.
12.
If a function in C++ does not return a value then its return type is denoted as
Correct Answer
B. Void
Explanation
In C++, when a function does not return a value, its return type is denoted as "void". The "void" keyword is used to indicate that the function does not return any value. This is often used for functions that perform certain actions or tasks without needing to return a result.
13.
The variables that are used to represent individual array element in an array is called as
Correct Answer
B. Subscripted variable
Explanation
The variables that are used to represent individual array elements in an array are called subscripted variables. These variables are used to access specific elements within the array by using their corresponding indices. The indices are typically integers that indicate the position of the element within the array. By using subscripted variables, programmers can easily manipulate and retrieve specific data from arrays.
14.
The array exforsys[10] can be declared using pointers as
Correct Answer
C. * exforsys[]
Explanation
The correct answer is * exforsys[]. This is because declaring an array using pointers requires the use of the asterisk (*) symbol before the array name. Therefore, * exforsys[] is the correct syntax for declaring the array exforsys[10] using pointers.
15.
What is the notation used to place a block of statements in a looping structure in C++?
Correct Answer
C. { }
Explanation
The correct answer is { }. In C++, a block of statements is enclosed within curly braces { } to define the body of a looping structure. These braces define the scope of the loop and allow multiple statements to be executed repeatedly until the loop condition is satisfied. The use of curly braces helps in organizing and grouping the statements within the loop, making the code more readable and maintainable.
16.
Index of an array starts from
Correct Answer
B. Zero
Explanation
The index of an array in most programming languages starts from zero. This means that the first element of an array is accessed using the index zero, the second element with index one, and so on. Therefore, the correct answer is "Zero".
17.
The variable that contains address of another variable is called as
Correct Answer
A. Pointer
Explanation
A pointer is a variable that stores the memory address of another variable. It allows us to indirectly access and manipulate the value of the variable it points to. In this case, the correct answer is "pointer" because it accurately describes a variable that contains the address of another variable. Arrays and unions are different concepts and do not specifically refer to a variable that holds the address of another variable. Therefore, they are not the correct answers.
18.
The operator that denotes address of a variable in C++ program is
Correct Answer
D. &
Explanation
The operator that denotes the address of a variable in C++ program is the ampersand symbol (&). This operator is used to retrieve the memory address of a variable, allowing for manipulation and access to that memory location.
19.
The notation of member access operator in structures is
Correct Answer
B. .
Explanation
The correct answer is ".". In C programming, the dot (.) operator is used to access the members of a structure. It is used to refer to a particular variable or function within the structure. For example, if we have a structure called "person" with members such as name and age, we can access them using the dot operator like person.name or person.age.
20.
One argument constructor is also called as
Correct Answer
B. Copy constructor
Explanation
A one-argument constructor is not called a "single constructor" because it can have multiple parameters. It is also not called a "copy constructor" because a copy constructor is a special type of constructor that takes an object of the same class as its parameter. Therefore, the correct answer is "None of the Above".
21.
The other name for external variables in C++ is
Correct Answer
C. Global variables
Explanation
The other name for external variables in C++ is global variables. In C++, global variables are declared outside of any function and can be accessed by any function within the program. They have a global scope and can be used throughout the entire program.
22.
What method is used for writing characters in a C++ program?
Correct Answer
A. Put
Explanation
The put method is used for writing characters in a C++ program.
23.
What will be the return type for a function named as exforsys declared as int exforsys (float x, double y)?
Correct Answer
B. Int
Explanation
The return type for the function named "exforsys" is int because the function declaration states that the return type is int. The function takes two parameters, a float x and a double y, but the return type is specifically defined as int.
24.
Which of the following options denotes the newline character in the C++ program?
Correct Answer
A. '\n'
Explanation
The correct answer is ''\n''. In C++, the escape sequence '\n' represents the newline character. When this escape sequence is used in a program, it creates a new line and moves the cursor to the beginning of the next line.
25.
Which of the following is used to group a set of global classes, objects and functions under a name?
Correct Answer
C. Namespaces
Explanation
Namespaces are used to group a set of global classes, objects, and functions under a name. They provide a way to organize code and prevent naming conflicts by encapsulating them within a specific scope. By using namespaces, different parts of a program can have their own separate set of names without interfering with each other. This helps in maintaining code clarity, modularity, and reusability.
26.
Cin in C++ program uses the operator
Correct Answer
A. >>
Explanation
In C++ programming, the "cin" statement is used to read input from the user. It uses the ">>" operator to extract data from the input stream and store it into variables. The ">>" operator is known as the extraction operator and it is used specifically with "cin" to read different types of data such as integers, floating-point numbers, characters, and strings.
27.
Which of the following values denotes an incorrect data type in C++?
Correct Answer
A. Real
Explanation
In C++, there is no data type called "real." The correct data types for representing real numbers with decimal points are "double" and "float." "double" is used for double-precision floating-point numbers, while "float" is used for single-precision floating-point numbers. "int" is used for integers. Therefore, "real" is not a valid data type in C++.
28.
The class that reads and writes to an array in memory is called ______.
Correct Answer
C. Strstream
Explanation
The class that reads and writes to an array in memory is called strstream.
29.
The new operator in C++
Correct Answer
C. Both A and B
Explanation
The correct answer is "Both A and B" because the new operator in C++ not only allocates memory for the object but also initializes the allocated memory. This means that when using the new operator to create an object, both memory allocation and initialization are performed automatically.
30.
What notation is used to represent destructors in the C++ program?
Correct Answer
D. ~
Explanation
The tilde (~) notation is used to represent destructors in the C++ program. Destructors are special member functions that are automatically called when an object goes out of scope or is explicitly deleted. They are used to clean up any resources or memory allocated by the object. The tilde (~) followed by the class name is used to define the destructor in C++ code.
31.
Virtual functions are defined in
Correct Answer
A. Derived class
Explanation
Virtual functions are defined in the derived class. This is because virtual functions are used in polymorphism, where different derived classes can have their own implementation of the same function declared in the base class. By defining the virtual function in the derived class, it allows for dynamic binding and the correct implementation of the function to be called based on the object's type at runtime.
32.
Which of the following notations will you use to compare two variables X and Y?
Correct Answer
A. X==Y
Explanation
The correct answer is X==Y. This is the correct notation to use when comparing two variables X and Y. The double equals sign (==) is used in many programming languages to check if two values are equal. It returns a boolean value of true if the variables are equal and false if they are not. The other notations provided are not correct for comparing variables.
33.
Comments in C++ program is written by using:
Correct Answer
A. //
Explanation
In C++ programming, comments are written using the double forward slash "//". This is a single-line comment that allows programmers to add explanatory or descriptive text within their code. The compiler ignores anything written after the "//" symbol, treating it as a comment and not executing it as code. This is useful for documenting the code, making it easier for other programmers to understand and maintain the code in the future.
34.
Which of the following is mandatory for all C++ program?
Correct Answer
A. Main()
Explanation
The correct answer is "main()". In C++, the main() function is mandatory for every program. It serves as the entry point of the program, where the execution begins. Without the main() function, the program will not be able to run or execute any code. Therefore, main() is essential and required in all C++ programs.
35.
Which of the following is returned by the operating system if a C++ program completes successfully?
Correct Answer
D. 0
Explanation
The operating system returns 0 if a C++ program completes successfully. This is a convention followed by most operating systems, where a return value of 0 indicates successful execution of the program.
36.
Which of the following is used in C++ to create a copy of an object?
Correct Answer
B. Copy constructor
Explanation
The copy constructor in C++ is used to create a copy of an object. It is a special constructor that takes an object of the same class as a parameter and creates a new object with the same values. This is useful when we want to create a new object that is an exact copy of an existing object. The assignment operator can also be used to create a copy of an object, but it is not specifically designed for this purpose like the copy constructor is. Therefore, the correct answer is B) Copy constructor.
37.
Which of the following exists in C++?
Correct Answer
A. Virtual destructor
Explanation
In C++, a virtual destructor exists. A virtual destructor is used to ensure that the destructor of a derived class is called when deleting a base class pointer that points to a derived class object. This is important to avoid memory leaks and ensure proper cleanup of resources allocated in the derived class. A virtual constructor, on the other hand, does not exist in C++. Therefore, the correct answer is virtual destructor.
38.
Which of the following denote advantages of inheritance?
Correct Answer
C. Both A and B
Explanation
Inheritance in programming allows for the reuse of code, as it allows a class to inherit properties and methods from another class. This promotes code reusability and saves time in program development, as developers do not need to write the same code multiple times. Therefore, the correct answer is "Both A and B," as both advantages mentioned in options A and B are true.