aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • C++ Programming Fundamentals
  • Consider the following C++ code: ```cpp class Sample { in...
Multiple choice

Consider the following C++ code:

class Sample {
    int a;

public:
    Sample(int b)
    {
        a = b;
    }
    Sample(Sample s)
    {
        a = s.a;
    }
};
void main()
{
    Sample s(100);
    Sample s1(s);
}

Referring to the above program code, what initialises the object s1?

  1. 1000

  2. Value of s object

  3. 200

  4. 300

  5. 400

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

This is the correct option.

Keep practicing — related questions

  • Consider the following C++ code: class Name{ int x,y; public: Name(int a, b=10) { x=a; }}; If an object of ...
  • What is the output of C++ program given below? #include<iostream> using namespace std; class Test { public:...
  • Identify the data member or the member variables in the above program. class A {public: int a;void display(...
  • Which of the following variables in C++ must be initialised at the time of declaration?
  • Find the output of the following code in C language, if assumed that all preprocessor directives are correc...
  • What will be the output of the following code? using System;class A { public void DemoA() { Console.WriteLi...
  • What will be the output of the following code? using System;using System.Collections.Generic;class A { publ...
  • Which of the following is true about the following code? using System;using System.Collections.Generic;clas...
Play the full quiz 🎤 Practise this topic out loud
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy