What will be the output of the following C++ code
#include
#include
using namespace std;
int main()
{
bitset<b1(95);
bitset<b2 = b1 >> cout<<b1<<endl<<b}
00001011
11111000
01111111
00001101
Browse topic-based C++ Interview practice sets.
45 practice sets · Page 1 of 3
What will be the output of the following C++ code
#include
#include
using namespace std;
int main()
{
bitset<b1(95);
bitset<b2 = b1 >> cout<<b1<<endl<<b}
00001011
11111000
01111111
00001101
What will be the output of the following C++ code
#include
#include
using namespace std;
int main()
{
bitset<b1(95);
bitset<b2 = b1 << cout<<b}
00001101
01110001
01111111
11111000
What happens when only one argument is supplied to flip() function?
All bits are flipped in a bitset
Bit corresponding to argument bit is flipped
First bit is flipped
All alternate bits are flipped in a bitset
What happens when no argument is supplied to flip() function?
All alternate bits are flipped in a bitset
First bit is flipped
All bits are flipped in a bitset
All bits are flipped to 1 in a bitset
What is the use of the flip function in bitset?
Used to flip a bit in a bitset
Used to flip all bits to 1
Used to flip bit(s) in a bitset
Used to flip alternate bits
Which of the following is correct?
Destructors can be virtual
Destructor definition starts with !
There can be more than one destructor in a class
Destructor is used to initialize objects
How destructor overloading is done?
No chance for destructor overloading
By changing the number of parameters
By changing the parameters type
By changing both the number of parameters and their type
What will be the output of the following C++ code
#include
using namespace std;
class A{
public:
int a;
A(){
cout<<"Constructor called";
}
} a;
int main(int argc, char const *argv[])
{
return}
Nothing printed
Constructor called
Error
Segmentation fault
What will be the output of the following C++ code
#include
using namespace std;
class A{
public:
int a;
A(){
cout<<"Constructor called";
}
};
int main(int argc, char const *argv[])
{
A a1 = (A)malloc(sizeof(A));
return}
Constructor called
Error
Nothing printed
Segmentation fault
What will be the output of the following C++ code
#include
using namespace std;
class A{
public:
int a;
A(int a=0){
this->a = a;
}
};
int main(int argc, char const *argv[])
{
A aa2(10);
cout<<a2.a;
return}
010
001
100
Error
What will be the output of the following C++ code
#include
using namespace std;
class A{
public:
int a;
A(int a){
this->a = a;
}
};
int main(int argc, char const *argv[])
{
A aa2(10);
cout<<a2.a;
return}
No output
Compile time error
Run-time error
10
What will be the output of the following C++ code
#include
using namespace std;
class A{
public:
int a;
};
int main(int argc, char const *argv[])
{
A a1 = {10};
A a2 = a cout<<a1.a<<a2.a;
return}
Segmentation fault
87368746
Error
1010
What will be the output of the following C++ code
#include
using namespace std;
class A{
public:
A(){
cout<<"Constructor called";
}
};
int main(int argc, char const *argv[])
{
A *a;
return}
Nothing printed
Error
Constructor called
Segmentation fault
What will be the output of the following C++ code
#include
using namespace std;
class A{
A(){
cout<<"Constructor called";
}
};
int main(int argc, char const *argv[])
{
A a;
return}
Constructor called
Segmentation fault
Error
Nothing printed
When a copy constructor is called?
All of the mentioned
When an object of the class is passed by value to a function
When an object of the class is returned by value
When an object is constructed based on another object of the same class
Which of the following constructors are provided by the C++ compiler if not defined in a class?
Assignment constructor
Copy constructor
All of the mentioned
Default constructor
Which of the following is correct?
An object is an instance of its class
An object is an instance of the data type of the class
A class is an instance of its objects
A class is an instance of the data type that the class have
Which of the following is used to make an abstract class?
By declaring a pure virtual function in a class
By using an abstract keyword in front of a class declaration
By using virtual keyword in front of a class declaration
By declaring a virtual function in a class
Which of the following is correct in C++?
Classes cannot have protected data members
Structure members are private by default
Class members are public by default
Structures can have member functions
Which of the following is correct?
Friend functions can access private members of a class
Friend functions can access protected members of a class
Friend functions can access public members of a class
All of the mentioned