Oracle Financial Services Campus Recruitment - 2012 - Aptitude C++

Oracle Financial Services Campus Recruitment - 2012

Aptitude Questions
 

BASIC COMPUTER KNOWLEDGE APTITUDE SECTION – Sample Questions

C++  Aptitude Questions
Basic level of the C++ assessment. No points will be deducted for wrong answers. Questions are from Fundamentals , Object Oriented Programming , Arrays, Strings, Files etc .


Question Number 1

What will be the output of the following program?

int main(){
if(cout << "Hello ")

{
cout<< "Universe \n";
}
else
{
cout<< "World \n";
}
return 0;
}

a. Universe
b. Hello Universe
c. World
d. Hello World


Question Number 2 
What will be the output of the following program?

#include<iostream.h>
int main()
{
int i, j =5;
{
for (i= 0; i<= j; i++)
cout << i;
j++;
}
return 0;
}

a. 024
b. 0123456
c. Prints an infinite loop
d. 012345


Question Number 3 
What will be the output of the following code sample?

#include <iostream>
using namespace std;
int main ()
{
int a, b;
int result;
a = 5;
b = 2;
a = ++a;
result = a - b;
cout << result;
return 0;
}

a. 4
b. 3
c. 5
d. Compiler error


Question Number 4 
What does the following expression find?

if(X%4==0&&X%100!=0||X%400==0)

a. Prime number
b. Armstrong numbers
c. Invalid expression
d. Leap year


Question Number 5
Which one of the following actions call the copy constructor?

a. Passing an argument by reference
b. Passing an argument by using a pointer
c. Passing an argument by value
d. All of these


Question Number 6 
What will be the output of the following program?

#include<iostream.h>
class node
{
public:
virtual void display(int i)
{
cout<<"Iam in node"<<endl;
}
virtual int display(int i)
{
cout<<"I am in overloaded display"<<endl;
}
};
class derived:public node
{
private:
void display()
{
cout<<"Iam in derived"<<endl;
}
};
int main()
{
node *n;
derived d;
n = &d;
n->display();
getch();
}

a. Compiler error
b. Iam in derived
c. I am in overloaded display
d. Iam in node


Question Number 7
How can the constructor handle a failure?

I. By returning a value as status.
II. By throwing exception.
III. No error handling can be done.

a. I only
b. II only
c. III only
d. I and II


Question Number 8
Which one of the following statements is TRUE about the following program?

#include<iostream.h>
class Base
{
public:
Base(void)
{
}
virtual ~Base(void){}=0;
};
int main ()
{
return 0;
}

a. Class inherited from base must override the destructor of base
b. Above code has a syntax error
c. Above code doesn't have any error
d. A destructor cannot be pure virtual


Question Number 9
What is the default access level assigned to members of a class?

a. Friendly
b. Private
c. Abstracted
d. Protected


Question Number 10
Which of the following is TRUE about Virtual Functions?

a. Virtual Functions of the Base class must always be implemented in its Derived class
b. Pure virtual function must never have a body
c. Pure virtual function cannot be static
d. The call to a Virtual Functions work slower than normal function calls


Question Number 11
Which one of the following statements holds good for C++?

a. When a base class is either Privately or Publicly inherited, the private members of the base class never gets inherited in the derived class
b. When a base class is either Privately or Publicly inherited, None of the members of the base class gets inherited in the derived class
c. When a base class is either Privately, Only private members of the base class gets inherited in the derived class
d. When a base class is either Privately or Publicly inherited, the private members of the base class gets inherited in the derived class too


Question Number 12
Which of the following are valid places from where a function can be invoked in C++?

a. main() function
b. Another function
c. Within itself
d. All of the above


Question Number 13
How many times does the loop execute?

#include <iostream.h>
int main(void)
{
static int i = 0;
do
{
++i;
}while(i>=10);
}

a. 1
b. 10
c. 0
d. Infinite


Question Number 14
What are member functions in C++?

a. Any nonstatic function declared outside a class declaration is called member function
b. Any static function declared inside a class declaration is called member function
c. Any static function declared outside a class declaration is called member function
d. Any nonstatic function declared inside a class declaration is called member function


Question Number 15
What will be the output of the following code ?

#include <iostream.h>
class A
{
public:
virtual void example()=0;
};
class B:public A
{
public:
void example()
{
cout<<"One";
}
};
class C:public A
{
public:
void example()
{
cout<<"Two";
}
};
void main()
{
A* arra[2];
B e1;
C e2;
arra[0]=&e1;
arra[1]=&e2;
arra[0]->example();
arra[1]->example();
}

a. One
b. No Output
c. OneTwo
d. Compiler error


Question Number 16
Which of the following header files are part of Standard Input/Output Library?

1. iostream
2. fstream
3. sstream
4. iomanip

a. 1 only
b. 2 & 3 only
c. 1 & 2 both
d. All of these


Question Number 17
Which class is the ifstream derived from?

a. istream
b. fstream
c. iostream
d. ofstream


Question Number 18
What will be the output of the following program?

int main(void)
{
char x[]={'h','e','l','l','o'};
x[sizeof(x+1)] = '\0';
cout << x;
return 0;
}

a. hell
b. hello followed by some junk values
c. Runtime error
d. hello


Question Number 19
What will be the correct way, if we want to read the file file.bin in binary mode and want to place the file pointer at the end?

a. ifstream myfile ("file.bin", ios::in | ios::app | ios::binary);
b. ofstream myfile ("file.bin", ios::in | ios::ate | ios::binary);
c. ofstream myfile ("file.bin", ios::in | ios::app | ios::binary);
d. ifstream myfile ("file.bin", ios::in | ios::ate | ios::binary);


Question Number 20
What will be the output of the following program?

#include <iostream.h>
int main ()
{
char myword [] = { 'H', 'e', 'l', 'l', 'o', '\0' };
char myword1 [] = "Hello";
cout<< myword<< " " << myword1;
}

a. Runtime error
b. Hello H
c. Hello Hello
d. Compiler error 

5 comments:

  1. interesting blog. It would be great if you can provide more details about it. Thanks you




    Financial Services - Niryuha

    ReplyDelete
  2. sir are you have any job details for me. i have completed JAVA, ASP, C, C++ please tell me on my email id - neha269@gmail.com

    ReplyDelete
  3. Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!



    ReplyDelete
  4. Thanks for sharing, I will bookmark and be back again




    Financial Services - Niryuha

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...