1.
What is reference variable in C++
Correct Answer
D. All
Explanation
A reference variable in C++ behaves like a pointer variable, as it holds the address of another variable. It can be used for call by reference, allowing the referenced variable to be modified within a function. Therefore, the correct answer is "all", as all the given statements accurately describe the characteristics and usage of reference variables in C++.
2.
A recursive function will be infinite recursive if the following were left out
Correct Answer
A. Base criteria
Explanation
If the base criteria were left out in a recursive function, there would be no condition to stop the recursion. The base criteria is the condition that determines when the recursive function should stop calling itself and return a value. Without this condition, the recursive function would continue to call itself indefinitely, resulting in an infinite recursion.
3.
Time taken to insert an element in a queue is
Correct Answer
C. O(n)
Explanation
The correct answer is O(n) because in a queue, elements are inserted at the rear end, and to insert an element, we need to traverse through all the existing elements in the queue until we reach the end. Therefore, the time complexity of inserting an element in a queue is directly proportional to the number of elements already present in the queue, which is represented as O(n).
4.
What are the 3 imp features of OOPS
Correct Answer
A. Encapsulation,inheritance,polymorpHism
Explanation
The three important features of Object-Oriented Programming (OOPS) are encapsulation, inheritance, and polymorphism. Encapsulation refers to the bundling of data and methods together, allowing access to the data only through defined methods. Inheritance enables the creation of new classes by inheriting properties and behaviors from existing classes, promoting code reuse. Polymorphism allows objects of different classes to be treated as objects of a common superclass, providing flexibility and extensibility in programming.
5.
Time taken to insert in to a linked queue
Correct Answer
C. O(nlog2n)
Explanation
The correct answer is O(nlog2n) because the time taken to insert an element into a linked queue is directly proportional to the number of elements already present in the queue. As the number of elements increases, the time taken to insert also increases. Additionally, the logarithmic factor (log2n) suggests that the time complexity grows at a slower rate compared to O(n), but still increases significantly as the size of the queue grows. Therefore, the time complexity for insertion in a linked queue is O(nlog2n).
6.
An application uses encapsulation to achive
Correct Answer
D. All
Explanation
Encapsulation in an application refers to the practice of bundling data and methods together within a class, hiding the internal details and providing a public interface for accessing and manipulating the data. This technique achieves information or data hiding by preventing direct access to the internal data, ensuring that it can only be modified through the defined methods. Additionally, encapsulation helps minimize independence among modules by allowing changes to be made to the internal implementation of a class without affecting other parts of the application. It also promotes implementation independence by providing a clear separation between the internal workings of a class and its external usage. Therefore, all of the given options are correct explanations for why an application uses encapsulation.
7.
OOP allow extension of object function or class of function.This ability with in OOP is called
Correct Answer
D. Scalabilty
Explanation
Scalability refers to the ability of a system or software to handle increasing amounts of work or to accommodate growth. In the context of Object-Oriented Programming (OOP), scalability refers to the ability to easily extend or add new functionality to objects or classes without affecting the existing code. This allows for the development of flexible and adaptable software systems that can easily accommodate changes and expansions in requirements.
8.
In single linked list we can traverse from back to front
Correct Answer
B. False
Explanation
In a single linked list, each node only has a reference to the next node, so it is not possible to traverse from back to front. To traverse a linked list, we start from the head node and follow the next pointers until we reach the end of the list. Therefore, the given statement is false.
9.
Using Double linked lists we can implement deque
Correct Answer
A. True
Explanation
A double linked list is a type of data structure that consists of nodes, where each node contains a reference to the previous and next node in the list. This allows for efficient insertion and deletion of elements at both ends of the list, making it suitable for implementing a deque (double-ended queue). Therefore, the statement that using double linked lists we can implement a deque is true.
10.
Application of satack is
Correct Answer
C. Recursion
Explanation
The correct answer is recursion. Recursion is a programming technique where a function calls itself to solve a problem by breaking it down into smaller subproblems. It is commonly used in algorithms and data structures to solve complex problems efficiently. In the given options, BFS (breadth-first search) and railway reservation are specific applications or use cases that can make use of recursion, but they are not the general application of recursion. The option "none" is incorrect as recursion is a valid application.
11.
In a Binary tree we can insert___________ nodes as its children
Correct Answer
B. 2
Explanation
In a binary tree, each node can have a maximum of two children. Therefore, we can insert a maximum of two nodes as children for each node in the binary tree.
12.
Friend function is
Correct Answer
B. Violates class property
Explanation
A friend function violates class property because it is not a member of the class, yet it has access to the private and protected members of the class. This breaks the principle of encapsulation, which aims to hide the internal details of a class and only allow access through member functions. Friend functions can be useful in certain cases, such as when they need to access multiple classes or when they require direct access to private members, but they should be used sparingly to maintain the integrity of the class.
13.
Abstract class
Correct Answer
B. Can be inherited
Explanation
An abstract class is a class that cannot be instantiated on its own, meaning you cannot create objects of that class. However, it can be inherited by other classes. Inheritance allows the child class to inherit the properties and methods of the abstract class, enabling code reuse and creating a hierarchical relationship between classes. Therefore, the correct answer is that an abstract class can be inherited.
14.
Can we use friend function for overlaoding= operator
Correct Answer
B. We can n't
Explanation
The correct answer is "we can't". This is because the assignment operator (=) cannot be overloaded using a friend function. The assignment operator can only be overloaded using a member function.
15.
Virtual base class is
Correct Answer
A. Usefull to avoid ambiguity in hybrid inheritance in accessing grand parent by grand child
Explanation
The virtual base class is useful in hybrid inheritance to avoid ambiguity when accessing the grandparent by the grandchild. This is because in hybrid inheritance, a class can inherit from multiple classes, which can lead to the same member being inherited multiple times. By making the base class virtual, it ensures that there is only one instance of the base class, resolving any ambiguity that may arise.
16.
Sparse matrix is
Correct Answer
B. Mostly with 0s
Explanation
A sparse matrix is mostly filled with zeros. In a sparse matrix, the majority of the elements are zero, while only a few elements have non-zero values. This characteristic of having mostly zeros makes sparse matrices different from dense matrices, where most of the elements are non-zero. Sparse matrices are commonly encountered in various fields, such as scientific computing and data analysis, where they help in efficient storage and computation by avoiding unnecessary calculations with zeros.
17.
A multiply list is
Correct Answer
D. B&c
Explanation
A multiply list is a list in which each node has multiple fields and is also used as a representation of a sparse matrix. This means that each node in the list contains multiple values or attributes, making it a versatile data structure. Additionally, it is specifically designed to efficiently store and manipulate sparse matrices, which have a large number of zero elements. Therefore, both options b and c are correct.
18.
Hashing is
Correct Answer
C. Address finding in random file organition
Explanation
Hashing is a technique used for address finding in random file organization. It involves the use of a hash function to map data elements to specific locations in a hash table or an array. This allows for quick retrieval of data based on its key or address, making it efficient for random access to files. Hashing is not related to header file inclusion or sequential file organization.
19.
In fold and method of hashing we can
Correct Answer
C. We can fold either from left or right or both sides
Explanation
The correct answer states that in the fold and method of hashing, we have the flexibility to fold either from the left or right side, or even both sides. This means that when using the fold method in hashing, we are not restricted to folding in a specific direction. We have the option to fold the data in whichever way is most suitable for the hashing process.
20.
We can overload ___ operators
Correct Answer
D. =
Explanation
The correct answer is "=" because the "=" operator can be overloaded in C++ to define a custom behavior for assignment operations between objects of a user-defined class. This allows for more flexibility and control over how objects are assigned values.
21.
If we use protected as access specifier in accessing base class ,the private member in base class becomes________ in derived class
Correct Answer
D. Not accessible
Explanation
When we use the "protected" access specifier in accessing the base class, the private member in the base class becomes "not accessible" in the derived class. This is because the "protected" access specifier allows the derived class to access the members of the base class, but it does not allow access to private members. Therefore, the private member in the base class cannot be accessed or inherited by the derived class.
22.
Containership in c++ refers to
Correct Answer
A. Declaring objects of a class as memebers in another class
Explanation
The correct answer is declaring objects of a class as members in another class. In C++, a containership refers to the practice of including objects of one class within another class. This allows for the creation of complex data structures and facilitates the organization and management of related data. By declaring objects of a class as members in another class, the container class can access and manipulate the data and functionality of the contained class.
23.
C++ was developed by
Correct Answer
D. Stroustrup
Explanation
C++ was developed by Bjarne Stroustrup.
24.
All search trees will have traversing techniques
Correct Answer
A. True
Explanation
The statement is stating that all search trees will have traversing techniques. This means that regardless of the specific type or structure of a search tree, there will always be techniques available to traverse or navigate through the tree. Therefore, the answer is true.
25.
The tree traversals are
Correct Answer
B. Inorder,preorder,postorder
Explanation
The correct answer is "inorder,preorder,postorder". These are the three common types of tree traversals. In inorder traversal, the left subtree is visited first, then the root, and finally the right subtree. Preorder traversal visits the root first, then the left subtree, and finally the right subtree. Postorder traversal visits the left subtree first, then the right subtree, and finally the root. These traversals are used to visit all the nodes in a tree in a specific order.