The Truth of Sisyphus
  • Introduction
  • Deep Learning
    • Basics
      • Hinge Loss
      • Regularizations
      • Linear Classification
      • Multi-Class and Cross Entropy Loss
      • Batch Norm and other Normalizations
      • Optimization
      • Optimization Functions
      • Convolution im2col
      • Activation Functions
      • Derivatives
        • Derivatives of Softmax
        • A Smooth (differentiable) Max Function
      • Model Ensemble
      • Layers Python Implementation
    • Classification
      • Mobile friendly networks
      • Non-local Neural Networks
      • Squeeze-and-Excitation Networks
      • Further Attention Utilization -- Efficience & Segmentation
      • Group Norm
      • ShuffleNet V2
    • Segmentation
      • Several Instance Segmentation
      • A Peek at Semantic Segmentation
      • Design Choices for Mobile Friendly Deep Learning Models, Semantic Segmentation
      • Efficient Video Object Segmentation via Network Modulation
      • BiSeNet
      • DeepLabV3+
    • Detection
      • CornerNet
      • IoU-Net
      • Why smooth L1 is popular in BBox Regression
      • MTCNN-NCNN
      • DetNet
      • SSD Illustration
    • RNN Related
      • GRU vs LSTM
      • BERT
    • Reinforcement Learning
      • AutoML in Practice Review
      • DRL for optimal execution of profolio transaction
    • Multi-task
      • Multi-task Overview
      • What are the tricks in Multi-Task network design?
    • Neural Network Interpretation
      • Neuron Visualization
    • Deep Learning Frameworks
      • How does Caffe work
      • [Gluon] When to use (Hybrid)Sequential and (Hybrid)Block
      • Gluon Hybrid Intro
      • Gluon HybridBlocks Walk-Through
      • A quick tour of Torch internals
      • NCHW / NHWC in Pytorch
      • Static & Dynamic Computation Graph
    • Converting Between DL Frameworks
      • Things To Be Considered When Doing Model Converting
      • Caffe to TensorFlow
    • Computation Graph Optimization
      • Two ways of TensorRT to optimize Neural Network Computation Graph
      • Customized Caffe Memory Optimization
      • NCNN Memory Optimization
      • Symbolic Programs Advantages: More Efficient, Reuse Intermediate Memory, Operation Folding
    • Deep Learning Debug
      • Problems caused by dead ReLU
      • Loss jumps to 87.3365
      • Common Causes of NANs During Training
    • Deployment
      • Efficient Convolution Operation
      • Quantization
    • What I read recently
      • Know Google the Paper Way
      • ECCV 2018
      • Neural Machine Translation
      • Street View OCR Extraction System
      • Teaching Machines to Draw
      • Pixel to Graph
      • Burst Image Deblurring
      • Material for Masses
      • Learning to Separate Object Sounds by Watching Unlabeled Video
    • Papers / Posts to be read
    • Dummy thoughts
  • Machine Learning
    • Classification
    • Regression
    • Clustering
    • Dimension Reduction
    • Metrics
    • Regularization
    • Bayesian Example
    • Machine Learning System Design
    • Recommendation
    • Essentials of Machine Learning
    • Linear Regression
    • Logistic Regression
      • Logistic Function
    • Gaussian Discriminant Analysis
    • Naive Bayes
    • SVM
    • MLE vs MAP
    • Boosting
    • Frequent Questions
    • Conclusion of Machine Learning
  • Python notes
    • Python _ or __ underscores usage
    • Python Multiprocess and Threading Differences
    • Heapq vs. Q.PriorityQueue
    • Python decorator
    • Understanding Python super()
    • @ property
    • Python __all__
    • Is Python List a Linked List or Array
    • What is the "u" in u'Hello world'
    • Python "self"
    • Python object and class
    • Python Class' Instance method, Class method, and Static Methods Demystified
    • Python WTF
    • Python find first value index in a list: [list].index(val)
    • Sort tuples, and lambda usecase
    • Reverse order of range()
    • Python check list is empty
    • Python get ASCII value from character
    • An A-Z of useful Python tricks
    • Python nested function variable scope
    • Python reverse a list
    • Python priority queue -- heapq
  • C++ Notes
    • Templates
    • std::string (C++) and char* (or c-string "string" for C)
    • C++ printf and cout
    • Class Member Function
    • Inline
    • Scope Resolution Operator ::
    • Constructor
    • Destructor
    • Garbage Collection is Critical
    • C++ Question Lists
  • Operating System
    • Basics
    • Mutex & Semaphore
    • Ticket Selling System
    • OS and Memory
    • Sort implementation in STL
    • Compile, link, loading & run
    • How to understand Multithreading and Multiprocessing from the view of Operating System
  • Linux & Productivity
    • Jupyter Notebook on Remote Server
    • Nividia-smi monitoring
  • Leetcode Notes
    • Array
      • 11. Container With Most Water
      • 35. Search Insert Position
    • Linked List
      • Difference between Linked List and Array
      • Linked List Insert
      • Design of Linked List
      • Two Pointers
        • 141. Linked List Cycle
        • 142. Linked List Cycle II
        • 160. Intersection of two Linked List
        • 19. Remove N-th node from the end of linked list
      • 206. Reverse Linked List
      • 203. Remove Linked List Elements
      • 328. Odd Even Linked List
      • 234. Palindrome Linked List
      • 21. Merge Two Sorted Lists
      • 430. Flatten a Multilevel Doubly Linked List
      • 430. Flatten a Multilevel Doubly Linked List
      • 708. Insert into a Cyclic Sorted List
      • 138. Copy List with Random Pointer
      • 61. Rotate List
    • Binary Tree
      • 144. Binary Tree Preorder Traversal
      • 94. Binary Tree Iterative In-order Traverse
    • Binary Search Tree
      • 98. Validate Binary Search Tree
      • 285. Inorder Successor in BST
      • 173. Binary Search Tree Iterator
      • 700. Search in a Binary Search Tree
      • 450. Delete Node in a BST
      • 701. Insert into a Binary Search Tree
      • Kth Largest Element in a Stream
      • Lowest Common Ancestor of a BST
      • Contain Duplicate III
      • Balanced BST
      • Convert Sorted Array to Binary Search Tree
    • Dynamic Programming
      • 198. House Robber
      • House Robber II
      • Unique Path
      • Unique Path II
      • Best time to buy and sell
      • Partition equal subset sum
      • Target Sum
      • Burst Ballons
    • DFS
      • Clone Graph
      • General Introduction
      • Array & String
      • Sliding Window
  • Quotes
    • Concert Violinist Joke
    • 船 Ship
    • What I cannot create, I do not understand
    • Set your course by the stars
    • To-do list
Powered by GitBook
On this page
  • What is the full form of OOPS?
  • What is a class?
  • What is an object?
  • List the types of inheritance supported in C++.
  • What is the role of protected access specifier?
  • What is encapsulation?
  • What is abstraction?
  • What is inheritance?
  • Explain the purpose of the keyword volatile.
  • What is an inline function?
  • What is a storage class?
  • Mention the storage classes names in C++.
  • What is the role of mutable storage class specifier?
  • Distinguish between shallow copy and deep copy.
  • What is a pure virtual function?
  • What is an abstract class in C++?
  • What is a reference variable in C++?
  • What is role of static keyword on class member variable?
  • Explain the static member function.
  • Name the data type which can be used to store wide characters in C++.
  • What are/is the operator/operators used to access the class members?
  • Can we initialize a class/structure member variable as soon as the same is defined?
  • What is the data type to store the Boolean value?
  • What is function overloading?
  • What is operator overloading?
  • Do we have a String primitive data type in C++?
  • Name the default standard streams in C++.
  • Which access specifier/s can help to achive data hiding in C++?
  • When a class member is defined outside the class, which operator can be used to associate the function definition to a particular class?
  • What is a constructor?
  • What is a destructor? Can it be overloaded?
  • What is a default constructor? Can we provide one for our class?
  • Which operator can be used in C++ to allocate dynamic memory?
  • What is the purpose of ‘delete’ operator?
  • Can I use malloc() function of C language to allocate dynamic memory in C++?
  • Can I use ‘delete’ operator to release the memory which was allocated using malloc() function of C language?
  • What is a friend function?
  • What is a friend class?
  • What is a copy constructor?
  • Does C++ supports exception handling? If so what are the keywords involved in achieving the same.
  • Explain the pointer – this.
  • What is the difference between the keywords struct and class in C++?
  • Can we implement all the concepts of OOPS using the keyword struct?
  • What is the block scope variable in C++?
  • What is the role of the file opening mode ios::trunk?
  • What is the scope resolution operator?
  • What are command line arguments?
  • What is a class template?
  • How can we catch all kind of exceptions in a single catch block?
  • What is keyword auto for?
  • What is a static variable?
  • What is the purpose of extern storage specifier.
  • What is the meaning of base address of the array?
  • When should we use the register storage specifier?
  • Can a program be compiled without main() function?
  • Where an automatic variable is stored?
  • What is a container class?
  • What is a token?
  • What is a preprocessor?
  • What are command line arguments?
  • What are the different ways of passing parameters to the functions? Which to use when?
  • What is reminder for 5.0 % 2?
  • Which compiler switch to be used for compiling the programs using math library with g++ compiler?
  • Can we resize the allocated memory which was allocated using ‘new’ operator?
  • Who designed C++ programming language?
  • Which operator can be used to determine the size of a data type/class or variable/object?
  • How can we refer to the global variable if the local and the global variable names are same?
  • What are valid operations on pointers?
  • What is recursion?
  • What is the first string in the argument vector w.r.t command line arguments?
  • What is the maximum length of an identifier?
  • What is the default function call method?
  • What are available mode of inheritance to inherit one class from another?
  • What is the difference between delete and delete[]?
  • Does an abstract class in C++ need to hold all pure virtual functions?
  • Is it legal to assign a base class object to a derived class pointer?
  • What happens if an exception is thrown outside a try block?
  • Are the exceptions and error same?
  • What is function overriding?
  • Which function is used to move the stream pointer for the purpose of reading data from stream?
  • Which function is used to move the stream pointer for the purpose of writing data from stream?
  • Are class functions taken into consideration as part of the object size?
  • Can we create and empty class? If so what would be the size of such object.
  • What is ‘std’?
  • What is the full form of STL?
  • What is ‘cout’?
  • What is ‘cin’?
  • What is the use of the keyword ‘using’?
  • If a pointer declared for a class, which operator can be used to access its class members?
  • What is difference between including the header file with-in angular braces < > and double quotes “ “
  • S++ or S = S+1, which can be recommended to increment the value by 1 and why?
  • What is the difference between actual and formal parameters?
  • What is the difference between variable declaration and variable definition?
  • Which key word is used to perform unconditional branching?
  • Is 068 a valid octal number?
  • What is the purpose of #undef preprocessor?
  • Can we nest multi line comments in a C++ code?
  • What is a virtual destructor?
  • What is the order of objects destroyed in the memory?
  1. C++ Notes

C++ Question Lists

These C++ Interview Questions have been designed specially to get you acquainted with the nature of questions you may encounter during your interview for the subject of C++. As per my experience good interviewers hardly plan to ask any particular question during your interview, normally questions start with some basic concept of the subject and later they continue based on further discussion and what you answer.

What is the full form of OOPS?

Object Oriented Programming System.

What is a class?

Class is a blue print which reflects the entities attributes and actions. Technically defining a class is designing an user defined data type.

What is an object?

An instance of the class is called as object.

List the types of inheritance supported in C++.

Single, Multilevel, Multiple, Hierarchical and Hybrid.

What is the role of protected access specifier?

If a class member is protected then it is accessible in the inherited class. However, outside both the private and the protected members are not accessible.

What is encapsulation?

The process of binding the data and the functions acting on the data together in an entity (class) called as encapsulation.

What is abstraction?

Abstraction refers to hiding the internal implementation and exhibiting only the necessary details.

What is inheritance?

Inheritance is the process of acquiring the properties of the exiting class into the new class. The existing class is called as base/parent class and the inherited class is called as derived/child class.

Explain the purpose of the keyword volatile.

Declaring a variable volatile directs the compiler that the variable can be changed externally. Hence avoiding compiler optimization on the variable reference.

What is an inline function?

A function prefixed with the keyword inline before the function definition is called as inline function. The inline functions are faster in execution when compared to normal functions as the compiler treats inline functions as macros.

What is a storage class?

Storage class specifies the life or scope of symbols such as variable or functions.

Mention the storage classes names in C++.

The following are storage classes supported in C++:

auto, static, extern, register and mutable

What is the role of mutable storage class specifier?

A constant class object’s member variable can be altered by declaring it using mutable storage class specifier. Applicable only for non-static and non-constant member variable of the class.

Distinguish between shallow copy and deep copy.

Shallow copy does memory dumping bit-by-bit from one object to another. Deep copy is copy field by field from object to another. Deep copy is achieved using copy constructor and or overloading assignment operator.

What is a pure virtual function?

A virtual function with no function body and assigned with a value zero is called as pure virtual function.

What is an abstract class in C++?

A class with at least one pure virtual function is called as abstract class. We cannot instantiate an abstract class.

What is a reference variable in C++?

A reference variable is an alias name for the existing variable. Which mean both the variable name and reference variable point to the same memory location. Therefore updation on the original variable can be achieved using reference variable too.

What is role of static keyword on class member variable?

A static variable does exit though the objects for the respective class are not created. Static member variable share a common memory across all the objects created for the respective class. A static member variable can be referred using the class name itself.

Explain the static member function.

A static member function can be invoked using the class name as it exits before class objects comes into existence. It can access only static members of the class.

Name the data type which can be used to store wide characters in C++.

wchar_t

What are/is the operator/operators used to access the class members?

Dot (.) and Arrow ( -> )

Can we initialize a class/structure member variable as soon as the same is defined?

No, Defining a class/structure is just a type definition and will not allocated memory for the same.

What is the data type to store the Boolean value?

bool, is the new primitive data type introduced in C++ language.

What is function overloading?

Defining several functions with the same name with unique list of parameters is called as function overloading.

What is operator overloading?

Defining a new job for the existing operator w.r.t the class objects is called as operator overloading.

Do we have a String primitive data type in C++?

No, it’s a class from STL (Standard template library).

Name the default standard streams in C++.

cin, cout, cerr and clog.

Which access specifier/s can help to achive data hiding in C++?

Private & Protected.

When a class member is defined outside the class, which operator can be used to associate the function definition to a particular class?

Scope resolution operator (::)

What is a constructor?

A constructor is the member function of the class which is having the same as the class name and gets executed automatically as soon as the object for the respective class is created.

What is a destructor? Can it be overloaded?

A destructor is the member function of the class which is having the same name as the class name and prefixed with tilde (~) symbol. It gets executed automatically w.r.t the object as soon as the object loses its scope. It cannot be overloaded and the only form is without the parameters.

What is a default constructor? Can we provide one for our class?

Every class does have a constructor provided by the compiler if the programmer doesn’t provides one and known as default constructor. A programmer provided constructor with no parameters is called as default constructor. In such case compiler doesn’t provides the constructor.

Which operator can be used in C++ to allocate dynamic memory?

‘new’ is the operator can be used for the same.

What is the purpose of ‘delete’ operator?

‘delete’ operator is used to release the dynamic memory which was created using ‘new’ operator.

Can I use malloc() function of C language to allocate dynamic memory in C++?

Yes, as C is the subset of C++, we can all the functions of C in C++ too.

Can I use ‘delete’ operator to release the memory which was allocated using malloc() function of C language?

No, we need to use free() of C language for the same.

What is a friend function?

A function which is not a member of the class but still can access all the member of the class is called so. To make it happen we need to declare within the required class following the keyword ‘friend’.

What is a friend class?

A class members can gain accessibility over other class member by placing the class declaration prefixed with the keyword ‘friend’ in the destination class.

What is a copy constructor?

A copy constructor is the constructor which take same class object reference as the parameter. It gets automatically invoked as soon as the object is initialized with another object of the same class at the time of its creation.

Does C++ supports exception handling? If so what are the keywords involved in achieving the same.

C++ does supports exception handling. try, catch & throw are keyword used for the same.

Explain the pointer – this.

This, is the pointer variable of the compiler which always holds the current active object’s address.

What is the difference between the keywords struct and class in C++?

By default the members of struct are public and by default the members of the class are private.

Can we implement all the concepts of OOPS using the keyword struct?

Yes.

What is the block scope variable in C++?

A variable whose scope is applicable only within a block is said so. Also a variable in C++ can be declared anywhere within the block.

What is the role of the file opening mode ios::trunk?

If the file already exists, its content will be truncated before opening the file.

What is the scope resolution operator?

The scope resolution operator is used to

  • Resolve the scope of global variables.

  • To associate function definition to a class if the function is defined outside the class.

What are command line arguments?

The arguments/parameters which are sent to the main() function while executing from the command line/console are called so. All the arguments sent are the strings only.

What is a class template?

A template class is a generic class. The keyword template can be used to define a class template.

How can we catch all kind of exceptions in a single catch block?

The catch block with ellipses as follows

catch(…) 
{
}

What is keyword auto for?

By default every local variable of the function is automatic (auto). In the below function both the variables ‘i’ and ‘j’ are automatic variables.

void f() 
{
   int i;
   auto int j;
}

NOTE − A global variable can’t be an automatic variable.

What is a static variable?

A static local variables retains its value between the function call and the default value is 0. The following function will print 1 2 3 if called thrice.

void f() 
{ 
   static int i; 
   
   ++i; 
   printf(“%d “,i); 
}

If a global variable is static then its visibility is limited to the same source code.

What is the purpose of extern storage specifier.

Used to resolve the scope of global symbol

#include <iostream>

using namespace std;	
main() {
   extern int i;
      
   cout<<i<<endl;
}
int i = 20;

What is the meaning of base address of the array?

The starting address of the array is called as the base address of the array.

When should we use the register storage specifier?

If a variable is used most frequently then it should be declared using register storage specifier, then possibly the compiler gives CPU register for its storage to speed up the look up of the variable.

Can a program be compiled without main() function?

Yes, it can be but cannot be executed, as the execution requires main() function definition.

Where an automatic variable is stored?

Every local variable by default being an auto variable is stored in stack memory

What is a container class?

A class containing at least one member variable of another class type in it is called so.

What is a token?

A C++ program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol.

What is a preprocessor?

Preprocessor is a directive to the compiler to perform certain things before the actual compilation process begins.

What are command line arguments?

The arguments which we pass to the main() function while executing the program are called as command line arguments. The parameters are always strings held in the second argument (below in args) of the function which is array of character pointers. First argument represents the count of arguments (below in count) and updated automatically by operating system.

main( int count, char *args[]) {
}

What are the different ways of passing parameters to the functions? Which to use when?

  • Call by value − We send only values to the function as parameters. We choose this if we do not want the actual parameters to be modified with formal parameters but just used.

  • Call by address − We send address of the actual parameters instead of values. We choose this if we do want the actual parameters to be modified with formal parameters.

  • Call by reference − The actual parameters are received with the C++ new reference variables as formal parameters. We choose this if we do want the actual parameters to be modified with formal parameters.

What is reminder for 5.0 % 2?

Error, It is invalid that either of the operands for the modulus operator (%) is a real number.

Which compiler switch to be used for compiling the programs using math library with g++ compiler?

Opiton –lm to be used as > g++ –lm <file.cpp>

Can we resize the allocated memory which was allocated using ‘new’ operator?

No, there is no such provision available.

Who designed C++ programming language?

Bjarne Stroustrup.

Which operator can be used to determine the size of a data type/class or variable/object?

sizeof

How can we refer to the global variable if the local and the global variable names are same?

We can apply scope resolution operator (::) to the for the scope of global variable.

What are valid operations on pointers?

The only two permitted operations on pointers are

  • Comparision ii) Addition/Substraction (excluding void pointers)

What is recursion?

Function calling itself is called as recursion.

What is the first string in the argument vector w.r.t command line arguments?

Program name.

What is the maximum length of an identifier?

Ideally it is 32 characters and also implementation dependent.

What is the default function call method?

By default the functions are called by value.

What are available mode of inheritance to inherit one class from another?

Public, private & protected

What is the difference between delete and delete[]?

Delete[] is used to release the array allocated memory which was allocated using new[] and delete is used to release one chunk of memory which was allocated using new.

Does an abstract class in C++ need to hold all pure virtual functions?

Not necessarily, a class having at least one pure virtual function is abstract class too.

Is it legal to assign a base class object to a derived class pointer?

No, it will be error as the compiler fails to do conversion.

What happens if an exception is thrown outside a try block?

The program shall quit abruptly.

Are the exceptions and error same?

No, exceptions can be handled whereas program cannot resolve errors.

What is function overriding?

Defining the functions within the base and derived class with the same signature and name where the base class’s function is virtual.

Which function is used to move the stream pointer for the purpose of reading data from stream?

seekg()

Which function is used to move the stream pointer for the purpose of writing data from stream?

seekp()

Are class functions taken into consideration as part of the object size?

No, only the class member variables determines the size of the respective class object.

Can we create and empty class? If so what would be the size of such object.

We can create an empty class and the object size will be 1.

What is ‘std’?

Default namespace defined by C++.

What is the full form of STL?

Standard template library

What is ‘cout’?

cout is the object of ostream class. The stream ‘cout’ is by default connected to console output device.

What is ‘cin’?

cin is the object of istream class. The stream ‘cin’ is by default connected to console input device.

What is the use of the keyword ‘using’?

It is used to specify the namespace being used in.

If a pointer declared for a class, which operator can be used to access its class members?

Arrow (->) operator can be used for the same

What is difference between including the header file with-in angular braces < > and double quotes “ “

If a header file is included with in < > then the compiler searches for the particular header file only with in the built in include path. If a header file is included with in “ “, then the compiler searches for the particular header file first in the current working directory, if not found then in the built in include path

S++ or S = S+1, which can be recommended to increment the value by 1 and why?

S++, as it is single machine instruction (INC) internally.

What is the difference between actual and formal parameters?

The parameters sent to the function at calling end are called as actual parameters while at the receiving of the function definition called as formal parameters.

What is the difference between variable declaration and variable definition?

Declaration associates type to the variable whereas definition gives the value to the variable.

Which key word is used to perform unconditional branching?

goto.

Is 068 a valid octal number?

No, it contains invalid octal digits.

What is the purpose of #undef preprocessor?

It will be used to undefine an existing macro definition.

Can we nest multi line comments in a C++ code?

No, we cannot.

What is a virtual destructor?

A virtual destructor ensures that the objects resources are released in the reverse order of the object being constructed w.r.t inherited object.

What is the order of objects destroyed in the memory?

The objects are destroyed in the reverse order of their creations.

PreviousGarbage Collection is CriticalNextOperating System

Last updated 6 years ago