C++ Programming Fundamentals
Comprehensive C++ programming concepts covering OOP, functions, operators, arrays, pointers, and file handling for MCA entrance and IT placement preparation
Questions
A function can also return an object.
- True
- False
Inline functions make a program run faster because the overhead of a function call & return is eliminated.
- True
- False
State whether the following function declaration with default values is valid or not?
int sum (int a=10,int b);
- Valid
- Invalid
Which one of the following is a user defined data type?
- Array
- Pointer
- Union
- Function
A protected member inherited in a public mode becomes _____________.
- public
- private
- protected
- none of these
Which one of the following statements is incorrect about static member functions?
- A static function can have access to only other static members declared in the same class.
- A static function can be called using the class name instead of its objects.
- The keyword static is used before the function name.
- None of the above.
The size of operator is a __________ operator.
- uniry
- binary
- logical
- relational
Given the following definition:
int i=10;
int *p;
Which of the following assignments is invalid?
- i=*p
- *p=i
- p=&i
- *p=&i
An object is a self-contained abstraction of an item.
- True
- False
What will be the output for the following?
#include<iostream.h>
{
int x[6]={62,45,7,10,82,90};
cout<<*x;
}
- 62
- 0
- 1
- 6
There are certain rules that must be followed during function calls, which are listed below. Read them carefully & find out which one of them is incorrect.
- Sequences of actual & formal parameters may differ.
- Numbers of actual & formal parameters must be the same.
- Types of actual & formal parameters must be the same.
- None of these
The variables which are associated with function name during function call are called _________.
- local variables
- formal variables
- global variables
- actual variables
Name the header file which is needed for the functions like read() and open()?
- iomanip.h
- stdio.h
- fstream.h
- iostream.h
What will be the output for the following?
int i=2;
if(i)
cout<<i++;
else
cout<< --i;
- 2
- 1
- 3
- 0
Polymorphism means a function with one name & many forms.
- True
- False
Destructors has the same name as that of a class, but with a prefix ' ~'.
- True
- False
Till the array elements are not given any specific values, they are supposed to contain garbage values.
- True
- False
What will be the output for the following?
enum color{pink,yellow,blue,black};
#include<iostream.h>
void main()
{
cout<<blue;
cout<<black;
}
- Blue Black
- 3 4
- 2 3
- None of the above
Array elements are always stored in contiguous memory locations.
- True
- False
Give the output for the following:
#include
int g=10;
void fun(int &x,int y)
{
x=x-y;
y=x*10;
cout<<x<<,<<y;
}
void main()
{
int g=5;
fun(::g,g);
}
- 0, 0
- -5, -50
- 10, 50
- 5, 50
Consider the following program & name the base class & the derived class.
#include
class A
{
int a;
public:
void getdata();
void putdata();
};
class B
{
int b;
public:
void cal();
};
class C: public A,B
{
public:
void show();
};
- Base class-B
Derived class-C - Base class-A & B
Derived class-C - Base class-A
Derived class-B & C - Base class-A
Derived class-C
The closing braces of structure are followed by a __________.
- colon
- dot
- semicolon
- none of the above
How many values can be returned by a function?
- 1
- 0
- Multiple
- They don't return any value
C++ allows us to declare a variable anywhere in the program.
- True
- False