C-Plus-Plus Questions

0 votes, 0 avg
7

C-Plus-Plus Questions

1 / 15

1. Which of the following constructors are provided by the C++ compiler if not defined in a class?

2 / 15

2. Observer the given C++ program carefully and choose the correct output from the given options:

#include   
#include   
using namespace std;  
int main()  
{  
    cout<::value; // case A  
    cout<::value; // case B  
    cout<::value;  // case c  
    return 0;  
}  

3 / 15

3. Where does the return statement returns the execution of the program?

4 / 15

4. Which of the following is correct about friend functions?

5 / 15

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

  #include 
   using namespace std;
   int main()
   {
       int a[2][4] = {3, 6, 9, 12, 15, 18, 21, 24};
       cout << *(a[1] + 2) << *(*(a + 1) + 2) << 2[1[a]];
       return 0;
   }

6 / 15

6. Which option is false for the following code?

class A
{
 private : int sum(int x, int y)
 { 
  return x+y; 
 }
 public: A()
 {  
 }
 A(int x, int y)
 { 
  cout<

7 / 15

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

#include 
#include 
using namespace std;
class Box
{
	int capacity;
    public:
	Box(int cap){
		capacity = cap;
	}
 
	friend void show();
};
 
void show()
{	
	Box b(10);
	cout<<"Value of capacity is: "<

8 / 15

8. what will be the output of the given program?

class base
{
public:
       base()
       {          
           cout<<"BCon";
       }
       ~base()
       {
	   cout<<"BDest ";
       }
};
class derived: public base
{
public:
       derived()
       {     cout<<"DCon ";
       }
       ~derived()
       {     cout<<"DDest ";
       }
};

int main()
{
derived object;
return 0; 
}

9 / 15

9. By which of the following can the if-else statement be replaced?

10 / 15

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

        #include 

        using namespace std;

        void copy (int& a, int& b, int& c)

        {

            a *= 2;

            b *= 2;

            c *= 2;

        }

        int main ()

        {

            int x = 1, y = 3, z = 7;

            copy (x, y, z);

            cout << "x =" << x << ", y =" << y << ", z =" << z;

            return 0;

        }

11 / 15

11. The correct statement for a function that takes pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to a integer is ____________

12 / 15

12. What is Pseudo-random number engines?

13 / 15

13. What is abstract class in C++?

14 / 15

14. What is the difference between delete and delete[] in C++?

15 / 15

15. How many times hello is printed?

int main()
{
    int i=0;
    lbl:
    cout<<"CppBuzz.com";
    i++;
    if(i<5)
    {
	goto lbl;
    }
return 0;

}

Your score is

The average score is 18%

0%