C++ Questions

Q:

A special member function of a class, which is invoked automatically whenever an object goes out of the scope is called

A) Constructor B) Destructor
C) Friend function D) None of the above
 
Answer & Explanation Answer: B) Destructor

Explanation:

Destructor is a special member function of a class, which is invoked automatically whenever an object goes out of the scope. It has the same name as its class with a tilde character prefixed.

Report Error

View Answer Report Error Discuss

Filed Under: C++
Job Role: Software Architect

1 4741
Q:

What is meant by pure virtual function?

A) Function which does not have definition of its own. B) Function which does have definition of its own.
C) Function which does not have any return type. D) None of the mentioned
 
Answer & Explanation Answer: A) Function which does not have definition of its own.

Explanation:

As the name itself implies, it have to depend on other class only.

Report Error

View Answer Report Error Discuss

Filed Under: C++

2 4736
Q:

What do you mean by inline function?

Answer

An inline function is a function that is expanded inline when invoked.ie. the compiler replaces the function call with the corresponding function code. An inline function is a function that is expanded in line when it is invoked. That is the compiler replaces the function call with the corresponding function code (similar to macro)

Report Error

View answer Workspace Report Error Discuss

Subject: C++
Job Role: Software Architect

1 4707
Q:

What is the difference between realloc() and free()?

Answer

The free subroutine frees a block of memory previously allocated by the malloc subroutine. Undefined results occur if the Pointer parameter is not a valid pointer. If the Pointer parameter is a null value, no action will occur. The realloc subroutine changes the size of the block of memory pointed to by the Pointer parameter to the number of bytes specified by the Size parameter and returns a new pointer to the block. The pointer specified by the Pointer parameter must have been created with the malloc, calloc, or realloc subroutines and not been deallocated with the free or realloc subroutines. Undefined results occur if the Pointer parameter is not a valid pointer.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 4677
Q:

What is mandatory for designing a new container?

A) Classes B) Iterators
C) Container D) None of these
 
Answer & Explanation Answer: B) Iterators

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: C++

0 4656
Q:

What will happen when an exception is not processed?

A) It will eat up lot of memory and program size B) Terminate the program
C) Crash the compiler D) None of the mentioned
 
Answer & Explanation Answer: A) It will eat up lot of memory and program size

Explanation:

As in the case of not using an exception, it will remain useless in the program and increase the code complexity.

Report Error

View Answer Report Error Discuss

Filed Under: C++

2 4637
Q:

What could be the bucket size if collision and overlapping occur at same time?

A) 2 B) 0
C) 1 D) 4
 
Answer & Explanation Answer: C) 1

Explanation:

One. If there is only one entry possible in the bucket, when the collision occurs, there is no way to accommodate the colliding value. This results in the overlapping of values

Report Error

View Answer Report Error Discuss

Filed Under: C++

1 4622
Q:

Values that are used to end loops are referred to as _____ values.

A) stop B) sentinel
C) end D) finish
 
Answer & Explanation Answer: B) sentinel

Explanation:
Report Error

View Answer Report Error Discuss

4 4602