0

Programming in C++

Description: Programming questions in C++ covers questions to test programming skills of students in development languages.
Number of Questions: 15
Created by:
Tags: C Programming questions C language questions programming in C C++. C++ language questions Programming in C and C++
Attempted 0/15 Correct 0 Score 0

Which of the following is the process of creating instances from classes?

  1. Inheritance

  2. Polymorphism

  3. Instantiation

  4. Data abstraction

  5. Platform independent


Correct Option: C
Explanation:

The process of creating instances from classes is called as Instantiation.

In C++, 'Car' is considered as which of the following?

  1. Object

  2. Attribute

  3. Class

  4. Structure

  5. String


Correct Option: C
Explanation:

In C++, 'Car' can be considered as class type because class would be the basic type and the various models of the cars forms the object of the class 'Car'.

Which of the following types of inheritance permits more than one super class and inherits features from all ancestors?

  1. Single inheritance

  2. Multiple inheritance

  3. Multilevel inheritance

  4. Hierarchical inheritance

  5. Polymorphism


Correct Option: B
Explanation:

This type of inheritance permits more than one super class and inherits features from all ancestors.

Which of the following is not a visibility mode in C++?

  1. Private

  2. Protected

  3. Public

  4. Friend

  5. Both private and public


Correct Option: D
Explanation:

This is not a visibility mode in C++ instead it is a type of function that can act as friend to any class and access its data members.

Which of the following operators in C++ cannot be overloaded?

  1. Arithmetic operator

  2. Relational operator

  3. Conditional operator

  4. Comparison operator

  5. Addition operator


Correct Option: C
Explanation:

This operator cannot be overloaded in C++ as it consist of (?:) symbol and requires a condition and two options.

Which of the following functions in C++ is used for performing short term calculation?

  1. Memory allocation function

  2. Inline function

  3. Member function

  4. Default function

  5. Friend function


Correct Option: B
Explanation:

This is the function in C++ used for performing short term calculation and consisting of one or two statements only.

What will be the output of the following C++ statement? cout<<4.5%3;

  1. 0

  2. 1

  3. 1.5

  4. 0.5

  5. 5


Correct Option: A
Explanation:

This is the correct option as the modular division holds the remainder as the result which is nothing but 0.

Which of the following is not a header file in C++?

  1. iostream.h

  2. conio.h

  3. stream.h

  4. stdlib.h

  5. ctype.h


Correct Option: C
Explanation:

There is no such header file being supported by C++.

Which of the following statements is the correct output statement in C++?

  1. cin>>"India";

  2. cin<<"India";

  3. cout<<"India";

  4. cout>>"India";

  5. cout<<India;


Correct Option: C
Explanation:

This is the correct option as the insertion operator is used and the statement is enclosed inside double quotes.

Which of the following is not an advantage of using function in C++ program?

  1. It debuggs a program easily.

  2. It consumes less disk space.

  3. Recursive calls to function is possible.

  4. Testing a program becomes easier.

  5. Complexity of a program is reduced.


Correct Option: B
Explanation:

This is the correct option as usage of function in the program consumes more disk space than without using a function.

Which of the following is a pointer to the current object, which is passed implicitly to an overloaded function in C++?

  1. This

  2. New

  3. Delete

  4. Private

  5. Scope


Correct Option: A
Explanation:

This is a pointer to the current object which is passed implicitly to an overloaded operator function in C++.

In C++, if a class is derived from another derived class, then what is it known as?

  1. Multiple inheritance

  2. Multilevel inheritance

  3. Single inheritance

  4. Hierarchical inheritance

  5. Protected inheritance


Correct Option: B
Explanation:

Deriving a class from another derived class is known as multilevel inheritance.

A class named employee must have a constructor whose name is ___________.

  1. employer

  2. ~employee

  3. constructor

  4. employee

  5. any legal C++ name


Correct Option: D
Explanation:

This is the correct option as constructor has the same name as that of class.

Which of the following statements in C++ creates an infinite loop?

  1. while(; ;)

  2. for(; ;)

  3. if(; ;)

  4. switch(; ;)

  5. do(; ;)


Correct Option: B
Explanation:

This is the correct option as for loop consist of three parts i.e, initialization ; condition; increment and if none of the part is not specified by the user then infinite loop is created.

Which of the following statement is true about function overloading?

  1. Calling a function from another function

  2. Calling a same function with different form

  3. Calling a function from itself

  4. Calling a same function in same form every time

  5. There is no such term in C++


Correct Option: B
Explanation:

This is the correct option as calling the same function in different form allows a user to perform multiple operation with the same function and hence called as function overloading.

- Hide questions