Assignment -1
Question: 1 //What is the output of below C++ program?
#include <iostream>
int main()
{
if(0)
{
std::cout<<"Hi";
}
else
{
std::cout<<"Bye";
}
return 0;
}
(A) Hi
(B) Bye
(C) HiBye
(D) Compilation Error
Question: 2 What is size of int data type in C++?
(A) 2 Bytes
(B) 4 Bytes
(C) 1 Byte
(D) Depends on Compiler
Question: 3 Which operator can not be overloaded in C++?
(A) +
(B) -
(C) *
(D) ::
Question: 4 //What should be the output of below C++ program?
#include<iostream>
int main()
{
int a=10;
std::cout<<a++;
return 0;
}
(A) 11
(B) 10
(C) Error
(D) 0
Question: 5 Can we overload functions in C++?
(A) Yes
(B) No
(C) Compilation Error
(D) Runtime Error
Question: 6 /What is output of below C++ program?
#include<iostream>
int main()
{
const int a=10;
a++;
std::cout<<a;
return 0;
}
(A) 10
(B) 11
(C) Compilation Error
(D) Linking Error
Question: 7 /What is the value of a in below C++ program?
int main()
{ int a, b=20;
a = 90/b;
return 0;
}
(A) 4.5
(B) 4.0
(C) 4
(D) Compilation Error
Question: 8
What is output of the below C++ program?
int main()
{
int a=10;
int b,c;
b = a++;
c = a;
std::cout<<a<<b<<c;
return 0;
}
(A) 111011
(B) 111111
(C) 101011
(D) 101010
Question: 9 #include<iostream>
class Mycpp
{
int Mycpp()
{
std::cout<<"Constructor";
return 0;
}
};
int main()
{
Mycpp obj;
return 0;
}
(A) Constructor
(B) 0
(C) Compilation Error
(D) Runtime Error
Question: 10 How many object can be created of a Class in C++?
(A) 1
(B) 5
(C) There is no limit
(D) 256
Question: 11 Which is not an integer data type?
(A) Single
(B) Byte
(C) Short
(D) Integer
Question: 12 A constructor is a special type of?
(A) class
(B) field
(C) function
(D) property
Question: 13 What is the purpose of 'default' keyword in C++?
(A) It instruct the compiler to set default value to any variable
(B) It instruct the compiler to set default return value to any function
(C) It instruct the compiler to set default argument values for any function
(D) It instruct the compiler to generate the default implementation