Sail E0 Webinar

MCQs

Total Questions : 10
Question 1.

How many types of models are available to create the user-defined data type?


  1.    1
  2.    2
  3.    3
  4.    4
 Discuss Question
Answer: Option B. -> 2

There are two types of models. They are references to built-in types and multipart types.


Question 2.

What is the scope of typedef defined data types?


  1.    inside that block only
  2.    whole program
  3.    outside the program
  4.    none of the mentioned
 Discuss Question
Answer: Option B. -> whole program

We are defining the user-defined data type to be availed only inside that program, if we want 

to use anywhere means we have to define those types in the header file.


Question 3.

How many types of user-defined data type are in c++?


  1.    1
  2.    2
  3.    3
  4.    4
 Discuss Question
Answer: Option C. -> 3

There are three types of user-defined data types. They are typedef, union, enumerator.


Question 4.

What is the syntax of user-defined data types?


  1.    typedef_existing data type_new name
  2.    typedef_new name_existing data type
  3.    def_existing data type_new name
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> typedef_existing data type_new name

None.


Question 5.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
typedef int num;
6.
typedef char let;
7.
let w = "steve";
8.
num a = 10, b = 15;
9.
num c = a + w;
10.
cout
  1.    10steve
  2.    steve10
  3.    compile time error
  4.    compile but not run
 Discuss Question
Answer: Option C. -> compile time error

error: invalid conversion from 'const char*' to 'let {aka char}'



Question 6.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int i;
6.
enum month {
7.
JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,DEC
8.
};
9.
for (i = JAN; i
  1.    012345678910
  2.    0123456789
  3.    01234567891011
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> 012345678910

In this program, we are defined the data types as enumerator and printing its value in a order.
Output:
$ g++ user1.cpp
$ a.out
012345678910


Question 7.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
typedef int num;
6.
num a = 10, b = 15;
7.
num c = a + b + a - b;
8.
cout
  1.    20
  2.    15
  3.    30
  4.    25
 Discuss Question
Answer: Option A. -> 20

In this program, we are manipulating the numbers and printing the result using user-defined 

data types.
Output:
$ g++ user.cpp
$ a.out
20


Question 8.

What does the data type defined by union will do?


  1.    It allow one different portion of memory to be accessed as same data types
  2.    It allow one same portion of memory to be accessed as same data types
  3.    It allow one different portion of memory to be accessed as different data types
  4.    It allow one same portion of memory to be accessed as different data types
 Discuss Question
Answer: Option D. -> It allow one same portion of memory to be accessed as different data types

Union is used to define the data types of our choice and it will store the data type in one 

location make them accessible.


Question 9.

Identify the correct statement.


  1.    typedef does not create different types.It only creates synonyms of existing types.
  2.    typedef create different types.
  3.    both a & b
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> typedef does not create different types.It only creates synonyms of existing types.

By using typedef, we can create a type of pre-existing type only not our own type of data.


Question 10.

Which keyword is used to define the user defined data types?


  1.    def
  2.    union
  3.    typedef
  4.    type
 Discuss Question
Answer: Option C. -> typedef

None.


Latest Videos

Latest Test Papers