Messho AI Ques Ans
Messho AI Ques Ans
Fix 'class Animal { / * some code */ };' for abstraction and inheritance?" class
Animal { virtual void sound ()=0; };' class Animal { virtual void sound(); };' class
Animal { void sound ()= 0 ; };' class Animal { void sound(); }
ans ;
class Animal {
public:
virtual void sound() = 0;
};
2:
COPS "Ensure 'class Vehicle \ /^ * some code */ };' for inheritance and
polymorphism?" class Vehicle { virtual void drive ()=0; };' class Vehicle
{ virtual void drive(); };' class Vehicle { void drive ()=0 };' class Vehicle { void
drive(); };
ANS:
class Vehicle {
public:
virtual void drive() = 0;
};
3 :)
Which layer of the OSI model is responsible for end-to-end communication? Physical
Layer Data Link Layer Transport Layer Network Layer
ans:
The layer of the OSI model that is responsible for end-to-end communication is the
Transport Layer.
4:
Error handling "Ensure 'throw std::over flow_error('Overflow!');' for
throwing an overflow error?" throw std::range_error('Overflow!');' throw
std::underflow_error('Overflow!');' throw std::overflow_error('Overflow!");
throw std::logic_error('Overf
ans :
throw std::overflow_error("Overflow!");
5)
hrow std::length_error('Invalid Argument!');' catch (...) { /* handle exception
/ }' catch (std::runtime_error e) { / handle exception / } catch
(std::length_error& e) { / handle exception catch (std::exception e) { //
exception */ }
ANS :)
catch (std::length_error& e) {
// handle exception
}
6:
What is the role of the SQL ROLLBACK statement? Save changes permanently Undo
changes made during a transaction Delete records from a table Retrieve data
Ans :
The role of the SQL ROLLBACK statement is to undo changes made during a
transaction. It is used to roll back or revert the database to the state it was in before
the transaction started, discarding any changes made within that transaction.
7:
n SQL, what is the purpose of the LIMIT clause? Filter records based on a condition Sort
records Specify the maximum number of rows to return Join multiple tables
ans)
The purpose of the SQL LIMIT clause is to specify the maximum number of
rows to return. It is commonly used in SELECT statements to limit the
number of rows returned by a query, which can be useful for pagination or
when you only need a specific subset of the result set.
8)
Find the error lines in the following code: 1 #include <stdio.h> 2 int main ()\
3 int arr[]= \{1, 2, 100\} 4 printf (^ prime \% d' , arr[3]); 5 return 0; 6}
ans ;
. Corrected the function declaration by adding the opening brace { after int
main().
. Corrected the array initialization by adding the closing brace } after {1, 2, 100}.
. Corrected the printf statement by replacing ^ with % and changing the array
index from [3] to [2].
9)
Find the error lines in the following code: 1 #include <stdio.h> 2 int main()
{ F 3 char name[100]; 4 gets(name); 5 printf('Hello %s!\n', name); 6 return 0;
7} A
Ans )
. Replaced the deprecated gets() function with fgets() to avoid potential
buffer overflow issues.
. Corrected the format specifier in the printf statement by using double
quotes (") instead of single quotes (').
10 )
Ensure 'std::list<int> myList; myList.clear();' for clearing elements in a list."
myList.delete_all();' myList.erase_all();' myList.clear();' myList.remove_all();'
ans )
myList.clear();
11)
Ensure 'std::unordered_map<int int> umap; umap.empty();' for checking if
an unordered_map is empty." umap.not_empty();' umap.empty();'
umap.is_empty();' umap.check_empty();"
Ans )
umap.empty();
12 )
What is the purpose of a Bloom filter in data structures? Sorting elements
Searching elements Checking membership of an element Storing key-value
pairs
ans)
Checking membership of an element.
13)
What is the main disadvantage of using a linear search algorithm? Slow for
large datasets Requires sorted data Inefficient for searching Consumes
excessive memor
ans)
he main disadvantage of using a linear search algorithm is:
14 )
Fix 'std::cout << std::setw(10) << std::setfill('0') << 25 : ' output?" setw(10)<< setfill (^
prime 0^ prime )^ prime setw(10)<< right < 25' setw(10)<<right< setfill (^ prime 0^
prime )^ prime right << setw(10) << setfill('0')
ans)
setw(10) << setfill('0')
15)
ans )
std::unique_ptr<int> ptr(new int(5));
16)
std::nth_element(vec.begin(), vec.begin() 3 , vec.end());' for finding the third
smallest element?" std::nth_element(vec.begin(), vec.begin() + 3, vec.end());'
std::nth_element(vec.begin(), vec.begin() + 2, vec.end());'
std::nth_element(vec.begin(), ver and vec.begin() + 3);'
std::nth_element(vec.begin(),
ans )
std::nth_element(vec.begin(), vec.begin() + 2, vec.end());
16)
"Ensure 'std::rotate(vec.begin(), vec.begin() 3 vec.end());' for cyclic rotation?"
std::rotate(vec.begin(), vec.begin() 3 vec.end());' std::rotate(vec.rbegin(),
vec.rbegin ()+ 3 , vec.rend()); std::rotate(vec.begin(), vec.begin() + 2,
vec.end());' std::rotate(vec.begin(), vec.b vec. begin ()+5);
ans)
std::rotate(vec.begin(), vec.begin() + 3, vec.end());
Verbal Questions:------------------------------------------------------------------------------------------------
17) Operating Systems Explain the concept of dynamic linking and its advantages in OS
design.
Inheritance Polymorphism.
19 What does the term "polymorphism" mean in OOP? Code reusability Multiple inheritance
One name, many forms Data hiding.
20) In SQL, what is the purpose of the LIMIT clause? Filter records based on a condition Sort
records Specify the maximum number of rows to return Join multiple tables
22) Explain the concept of ACID properties and their importance in a DBMS.
Left 4 questions