What is the output of the following code snippet?
#include
using namespace std;
void test (int x)
{
try
{
if (x > 0)
throw x;
else
}
throw 'x';
catch (int x)
{
cout<<"integer:"< }
catch(char x)
{
cout << "character:" << x< }
}
int main()
{
test (10);
test (0);
}
integer:10
integer:10 character:x
character:x
compilation error occurred
Answer: Option B.
Analyse the following code snippet :
Class Temp
{
private:
char m_acEmpName[25];
public:
char* GetFirstChar()
{
strcpy(m_acEmpName,"Hello");
return this->m_acEmpName;
}
};
int main(int argc, char ** argv)
{
Temp oTempObject; cout< }
Displays the first character of the string
Displays the complete string Hello
Error
Displays the last character of the string
Answer: Option B .
Assume that the Point class is existing with the following snippet in the header file
Point.h:
class Point
{
Point(); Pont(int, int); int GetX();
int GetY();
void SetX(int);
void SetY(int);
};
If the objects of Point are created as Point oPointOne, oPointTwo(2,3); Which of the following statements are correct?
(i) The statement oPointOne.SetX(20);
Will compile and run successfully.
(ii) The statement oPointOne.SetX(20).SetY(30);
Will compile successfully but will give a run time error.
Only (i) is correct
Both (i) and (ii) are correct
Both (i) and (ii) are incorrect
Only (ii) is correct
Answer: Option A .
What is the function of application programs in the DBMS approach?
To store data
To process functions
to access control
all of the above
Answer: Option B.
What is the complexity of this algorithm?
Algorithm Sum(a,n)
{
s := 0.0;
for i := 1 to n do s := s + a [i];
return s;