C++ Programming Fundamentals

Comprehensive C++ programming concepts covering OOP, functions, operators, arrays, pointers, and file handling for MCA entrance and IT placement preparation

25 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

A function can also return an object.

  1. True
  2. False
Question 2 Multiple Choice (Single Answer)

Inline functions make a program run faster because the overhead of a function call & return is eliminated.

  1. True
  2. False
Question 3 Multiple Choice (Single Answer)

State whether the following function declaration with default values is valid or not?
int sum (int a=10,int b);

  1. Valid
  2. Invalid
Question 4 Multiple Choice (Single Answer)

Which one of the following is a user defined data type?

  1. Array
  2. Pointer
  3. Union
  4. Function
Question 5 Multiple Choice (Single Answer)

A protected member inherited in a public mode becomes _____________.

  1. public
  2. private
  3. protected
  4. none of these
Question 6 Multiple Choice (Single Answer)

Which one of the following statements is incorrect about static member functions?

  1. A static function can have access to only other static members declared in the same class.
  2. A static function can be called using the class name instead of its objects.
  3. The keyword static is used before the function name.
  4. None of the above.
Question 7 Multiple Choice (Single Answer)

The size of operator is a __________ operator.

  1. uniry
  2. binary
  3. logical
  4. relational
Question 8 Multiple Choice (Single Answer)

Given the following definition:
int i=10;
int *p;
Which of the following assignments is invalid?

  1. i=*p
  2. *p=i
  3. p=&i
  4. *p=&i
Question 9 Multiple Choice (Single Answer)

An object is a self-contained abstraction of an item.

  1. True
  2. False
Question 10 Multiple Choice (Single Answer)

What will be the output for the following?
#include<iostream.h>
{
int x[6]={62,45,7,10,82,90};
cout<<*x;
}

  1. 62
  2. 0
  3. 1
  4. 6
Question 11 Multiple Choice (Single Answer)

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.

  1. Sequences of actual & formal parameters may differ.
  2. Numbers of actual & formal parameters must be the same.
  3. Types of actual & formal parameters must be the same.
  4. None of these
Question 12 Multiple Choice (Single Answer)

The variables which are associated with function name during function call are called _________.

  1. local variables
  2. formal variables
  3. global variables
  4. actual variables
Question 13 Multiple Choice (Single Answer)

Name the header file which is needed for the functions like read() and open()?

  1. iomanip.h
  2. stdio.h
  3. fstream.h
  4. iostream.h
Question 14 Multiple Choice (Single Answer)

What will be the output for the following?
int i=2;
if(i)
cout<<i++;
else
cout<< --i;

  1. 2
  2. 1
  3. 3
  4. 0
Question 15 Multiple Choice (Single Answer)

Polymorphism means a function with one name & many forms.

  1. True
  2. False
Question 16 Multiple Choice (Single Answer)

Destructors has the same name as that of a class, but with a prefix ' ~'.

  1. True
  2. False
Question 17 Multiple Choice (Single Answer)

Till the array elements are not given any specific values, they are supposed to contain garbage values.

  1. True
  2. False
Question 18 Multiple Choice (Single Answer)

What will be the output for the following?
enum color{pink,yellow,blue,black};
#include<iostream.h>
void main()
{
cout<<blue;
cout<<black;
}

  1. Blue Black
  2. 3 4
  3. 2 3
  4. None of the above
Question 19 Multiple Choice (Single Answer)

Array elements are always stored in contiguous memory locations.

  1. True
  2. False
Question 20 Multiple Choice (Single Answer)

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);
}

  1. 0, 0
  2. -5, -50
  3. 10, 50
  4. 5, 50
Question 21 Multiple Choice (Single Answer)

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();
};

  1. Base class-B
    Derived class-C
  2. Base class-A & B
    Derived class-C
  3. Base class-A
    Derived class-B & C
  4. Base class-A
    Derived class-C
Question 22 Multiple Choice (Single Answer)

The closing braces of structure are followed by a __________.

  1. colon
  2. dot
  3. semicolon
  4. none of the above
Question 23 Multiple Choice (Single Answer)

How many values can be returned by a function?

  1. 1
  2. 0
  3. Multiple
  4. They don't return any value
Question 24 Multiple Choice (Single Answer)

C++ allows us to declare a variable anywhere in the program.

  1. True
  2. False