Class 7 Exam  >  Class 7 Tests  >  Test: C++ Functions - Class 7 MCQ

Test: C++ Functions - Class 7 MCQ


Test Description

15 Questions MCQ Test - Test: C++ Functions

Test: C++ Functions for Class 7 2024 is part of Class 7 preparation. The Test: C++ Functions questions and answers have been prepared according to the Class 7 exam syllabus.The Test: C++ Functions MCQs are made for Class 7 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: C++ Functions below.
Solutions of Test: C++ Functions questions in English are available as part of our course for Class 7 & Test: C++ Functions solutions in Hindi for Class 7 course. Download more important topics, notes, lectures and mock test series for Class 7 Exam by signing up for free. Attempt Test: C++ Functions | 15 questions in 15 minutes | Mock test for Class 7 preparation | Free important questions MCQ to study for Class 7 Exam | Download free PDF with solutions
Test: C++ Functions - Question 1

What happens to a function defined inside a class without any complex operations (like looping, a large number of lines, etc)?

Detailed Solution for Test: C++ Functions - Question 1

Any function which is defined inside a class and has no complex operations like loops, a large number of lines then it is made inline.

Test: C++ Functions - Question 2

An inline function is expanded during ______________

Detailed Solution for Test: C++ Functions - Question 2

An inline function is expanded during the compile-time of a program.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: C++ Functions - Question 3

When we define the default values for a function?

Detailed Solution for Test: C++ Functions - Question 3

Default values for a function is defined when the function is declared inside a program.

Test: C++ Functions - Question 4

If an argument from the parameter list of a function is defined constant then _______________

Detailed Solution for Test: C++ Functions - Question 4

A function is not allowed a constant member of the parameter list.

Test: C++ Functions - Question 5

What will be the output of the following C++ code?

#include<iostream>
using namespace std;
 
int fun(int x = 0, int y = 0, int z)
{  return (x + y + z); }
 
int main()
{
   cout << fun(10);
   return 0;
}

Detailed Solution for Test: C++ Functions - Question 5

Default arguments should always be declared at the rightmost side of the parameter list but the above function has a normal variable at the rightmost side which is a syntax error, therefore the function gives an error.

Test: C++ Functions - Question 6

What will be the output of the following C++ code?

#include <iostream>
using namespace std;
 
int fun(int=0, int = 0);
 
int main()
{
  cout << fun(5);
  return 0;
}
int fun(int x, int y) { return (x+y); }

Detailed Solution for Test: C++ Functions - Question 6

C++ allows to define such prototype of the function in which you are not required to give variable names only the default values. While in function definition you can provide the variable names corresponding to each parameter.

Test: C++ Functions - Question 7

From which function the execution of a C++ program starts?

Detailed Solution for Test: C++ Functions - Question 7

The execution of a C++ program starts from the main() function.

Test: C++ Functions - Question 8

Which of the following is the default return value of functions in C++?

Detailed Solution for Test: C++ Functions - Question 8

C++ uses int as the default return values for functions. It also restricts that the return type of the main function must be int.

Test: C++ Functions - Question 9

What is an inline function?

Detailed Solution for Test: C++ Functions - Question 9

Inline function is those which are expanded at each call during the execution of the program to reduce the cost of jumping during execution.

Test: C++ Functions - Question 10

In which of the following cases inline functions may not word?
i) If the function has static variables.
ii) If the function has global and register variables.
iii) If the function contains loops
iv) If the function is recursive

Detailed Solution for Test: C++ Functions - Question 10

A function is not inline if it has static variables, loops or the function is having any recursive calls.

Test: C++ Functions - Question 11

Where should default parameters appear in a function prototype?

Detailed Solution for Test: C++ Functions - Question 11

Default parameters are defined to the rightmost side of parameter list in a function to differentiate between the normal and default parameters for example if a function is defined as fun(int x = 5, int y) then if we call fun(10) then 10 should be given to x or y because one can apply both logics like x = 10 already defined and 10 passed is for y but if compiler reads it from left to right it will think it is for x and no parameter is given for y, therefore, the compiler will give error.

Test: C++ Functions - Question 12

Which of the following feature is used in function overloading and function with default argument?

Detailed Solution for Test: C++ Functions - Question 12

Both of the above types allows a function overloading which is the basic concept of Polymorphism.

Test: C++ Functions - Question 13

What will be the output of the following C++ code?

#include<iostream>
using namespace std;
 
class Test
{
  protected:
    int x;
  public:
    Test (int i):x(i) { }
    void fun() const  { cout << "fun() const " << endl; }
    void fun()        {  cout << "fun() " << endl;     }
};
 
int main()
{
    Test t1 (10);
    const Test t2 (20);
    t1.fun();
    t2.fun();
    return 0;
}

Detailed Solution for Test: C++ Functions - Question 13

As the object declared are of two types one is normal object and other is constant object So normal objects calls normal fun() whereas constant objects calls constant fun().

Test: C++ Functions - Question 14

What will be the output of the following C++ code?

#include <iostream>
using namespace std;
void square (int *x, int *y)
{
    *x = (*x) * --(*y);
}
int main ( )
{
    int number = 30;
    square(&number, &number);
    cout << number;
    return 0;
}

Detailed Solution for Test: C++ Functions - Question 14

As we are passing value by reference therefore the change in the value is reflected back to the passed variable number hence value of number is changed to 870.

Test: C++ Functions - Question 15

Which of the following is important in a function?

Detailed Solution for Test: C++ Functions - Question 15

The important things required in a function is its return type and its name other than that parameter list are optional which a function may or may not have.

Information about Test: C++ Functions Page
In this test you can find the Exam questions for Test: C++ Functions solved & explained in the simplest way possible. Besides giving Questions and answers for Test: C++ Functions, EduRev gives you an ample number of Online tests for practice

Top Courses for Class 7

Download as PDF

Top Courses for Class 7