0% found this document useful (0 votes)
5 views18 pages

Mock Sample Interview Questions

The document contains a comprehensive list of interview questions and answers related to the C and C++ programming languages. It covers topics such as features of C, data types, memory management, functions, recursion, object-oriented programming concepts, and differences between C and C++. Additionally, it includes explanations of various operators, control statements, and programming principles relevant to both languages.

Uploaded by

D Pavithra Cyber
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views18 pages

Mock Sample Interview Questions

The document contains a comprehensive list of interview questions and answers related to the C and C++ programming languages. It covers topics such as features of C, data types, memory management, functions, recursion, object-oriented programming concepts, and differences between C and C++. Additionally, it includes explanations of various operators, control statements, and programming principles relevant to both languages.

Uploaded by

D Pavithra Cyber
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Sample interview questions

1) What are the features of the C language?


1. Simple
2. Portable
3. Midlevel
4. Structured
5. Fast speed
6. Memory management
7. Extensible

2) List some format specifiers in C ?

o %d: It is a format specifier used to print an integer value.


o %s: It is a format specifier used to print a string.
o %c: It is a format specifier used to display a character value.
o %f: It is a format specifier used to display a floating point value.

3) Difference between local and global variable in C ?


Declaration ,scope,acess,life,storage

4) What is the use of a static variable in C ?

o A variable which is declared as static is known as a static variable. The static variable
retains its value between multiple function calls.
o Static variables are used because the scope of the static variable is available in the entire
program. So, we can access a static variable anywhere in the program.
o The static variable is initially initialized to zero. If we update the value of a variable, then
the updated value is assigned.
o The static variable is used as a common value which is shared by all the methods.
o The static variable is initialized only once in the memory heap to reduce the memory usage.

5) What is the use of the function in C?

o C functions are used to avoid the rewriting the same code again and again in our program.
o C functions can be called any number of times from any place of our program.
o When a program is divided into functions, then any part of our program can easily be
tracked.
o C functions provide the reusability concept, i.e., it breaks the big task into smaller tasks so
that it makes the C program more understandable.

6) What is recursion in C?
When a function calls itself, and this process is known as recursion. The function that
calls itself is known as a recursive function.

7) What are the 2 phases of recursion ?

1. Winding phase
2. Unwinding phase

Winding phase: When the recursive function calls itself, and this phase ends when the condition
is reached.

Unwinding phase: Unwinding phase starts when the condition is reached, and the control returns
to the original call.

8) Define Array ?
An Array is a group of similar types of elements. It has a contiguous memory location. It
makes the code optimized, easy to traverse and easy to sort.
9) What is a pointer in C?
A pointer is a variable that refers to the address of a value. It makes the code optimized and
makes the performance fast.
10) What is the structure ?
The structure is a user-defined data type that allows storing multiple types of data in a single
unit. It occupies the sum of the memory of all members.
11) Can we compile a program without main() function?
Yes, we can compile, but it can't be executed.
12) What is the acronym for ANSI?
The ANSI stands for " American National Standard Institute
13) Can we access the array using a pointer in C language?
Yes, by holding the base address of array into a pointer, we can access the array using a
pointer.
14) What is typecasting?
The typecasting is a process of converting one data type into another is known as typecasting

15) What is an infinite loop?


A loop running continuously for an indefinite number of times is called the infinite loop.
16) What is an auto keyword in C?
In C, every local variable of a function is known as an automatic (auto) variable.
17) What is a union?
The union is a user-defined data type that allows storing multiple types of data in a single
unit.
18) What is the difference between malloc() and calloc()?
calloc() and malloc() are memory dynamic memory allocating functions. The only
difference between them is that calloc() will load all the assigned memory locations with value 0
but malloc() will not.
19) What is dynamic memory allocation?
In case of dynamic memory allocation, memory is allocated at runtime and memory can be
increased while executing the program. It is used in the linked list.
20) What is dangling pointer in C?
If a pointer is pointing any memory location, but meanwhile another pointer deletes the
memory occupied by the first pointer while the first pointer still points to that memory location,
the first pointer will be known as a dangling pointer
21) What is the purpose of sprintf() function?
The sprintf() stands for "string print." The sprintf() function does not print the output on
the console screen. It transfers the data to the buffer. It returns the total number of characters
present in the string.
22) Difference between union and structure
A struct is a group of complex data structures stored in a block of memory where each
member on the block gets a separate memory location to make them accessible at once

Whereas in the union, all the member variables are stored at the same location on the
memory as a result to which while assigning a value to a member variable will change the value
of all other members.
23) What is a token?
The Token is an identifier. It can be constant, keyword, string literal, etc. A token is the
smallest individual unit in a program
24) What is command line argument?
The argument passed to the main() function while executing the program is known as
command line argument.
25) Why n++ execute faster than n+1 ?
n++ being a unary operation, it just needs one variable. Whereas, n = n + 1 is a binary
operation that adds overhead to take more time (also binary operation: n += 1).
26) What is the difference between ‘g’ and “g” in C?
In C double-quotes variables are identified as a string whereas single-quoted variables
are identified as the character. Another major difference being the string (double-quoted)
variables end with a null terminator that makes it a 2 character array
27) What are the basic Datatypes supported in C Programming Language?
The Datatypes in C Language are broadly classified into 4 categories. They are as follows:
1. Basic Datatypes
2. Derived Datatypes
3. Enumerated Datatypes
4. Void Datatypes
28) What are the valid places where the programmer can apply Break Control Statement?
Break Control statement is valid to be used inside a loop and Switch control statements.
29) Differentiate between Actual Parameters and Formal Parameters.
The Parameters which are sent from main function to the subdivided function are called as
Actual Parameters and the parameters which are declared a the Subdivided function end are
called as Formal Parameters.
30) Where can we not use &(address operator in C)?
We cannot use & on constants and on a variable which is declared using the register
storage class.

31) What is the difference between C and C++?

The main difference between C and C++ are provided in the table below:
C C++

C++ is an object-oriented programming


C is a procedure-oriented programming language.
language.

Data is hidden by encapsulation to ensure


C does not support data hiding. that data structures and operators are used as
intended.

C is a subset of C++ C++ is a superset of C.

Function and operator overloading are not Function and operator overloading is
supported in C supported in C++

Namespace is used by C++, which avoids


Namespace features are not present in C
name collisions.

Functions can not be defined inside structures. Functions can be defined inside structures.

calloc() and malloc() functions are used for new operator is used for memory allocation
memory allocation and free() function is used for and deletes operator is used for memory
memory deallocation. deallocation.

32) What is the difference between struct and class?

In C++ a structure is the same as a class except for a few differences like security. The difference
between struct and class are given below:

Structure Class

Members of the class are private by


Members of the structure are public by default.
default.

When deriving a struct from a class/struct, default access When deriving a class, default
specifiers for base class/struct are public. access specifiers are private.

33) What is operator overloading?


Operator Overloading is a very essential element to perform the operations on user-
defined data types. By operator overloading we can modify the default meaning to the operators
like +, -, *, /, <=, etc.
34) What is polymorphism in C++?
Polymorphism in simple means having many forms. Its behavior is different in different
situations. And this occurs when we have multiple classes that are related to each other by
inheritance.
35) What are the 2 different types of polymorphism?
*Compile time polymorphism(Function overloading, Operator overloading)
*Rum time polymorphism(Function overriding, virtual function)

36) Explain constructor in C++


The constructor is a member function that is executed automatically whenever an object is
created. Constructors have the same name as the class
37) what is a virtual function in c++?
A C++ virtual function is a member function in the base class that you redefine in a derived
class. It is declared using the virtual keyword.
38) What do you know about friend class and friend function?
A friend class can access private, protected, and public members of other classes in which
it is declared as friends.
Like friend class, friend function can also access private, protected, and public members.
But, Friend functions are not member functions.
39) What are the C++ access specifiers?
In C++ there are the following access specifiers:
Public: All data members and member functions are accessible outside the class.
Protected: All data members and member functions are accessible inside the class and to the
derived class.
Private: All data members and member functions are not accessible outside the class.
40) Define inline function
If a function is inline, the compiler places a copy of the code of that function at each
point where the function is called at compile time. One of the important advantages of using an
inline function is that it eliminates the function calling overhead of a traditional function.
41) What do you mean by abstraction in C++?
Abstraction is the process of showing the essential details to the user and hiding the
details which we don’t want to show to the user or hiding the details which are irrelevant to a
particular user
42) Is deconstructor overloading possible? If yes then explain and if no then why?
No destructor overloading is not possible. Destructors take no arguments, so there’s only
one way to destroy an object. That’s the reason destructor overloading is not possible
43) What is an abstract class and when do you use it?
A class is called an abstract class whose objects can never be created. Such a class exists
as a parent for the derived classes. We can make a class abstract by placing a pure virtual
function in the class

44) What are destructors in C++?


A constructor is automatically called when an object is first created. Similarly when an
object is destroyed a function called destructor automatically gets called. A destructor has the
same name as the constructor (which is the same as the class name) but is preceded by a tilde.(~)
45) Explain inheritance
Inheritance is the process of creating new classes, called derived classes, from existing
classes. These existing classes are called base classes. The derived classes inherit all the
capabilities of the base class but can add new features and refinements of their own.
46) What is a copy constructor?
A copy constructor is a member function that initializes an object using another object of
the same class.
47) What is the difference between virtual functions and pure virtual functions?
A virtual function is a member function in the base class that you redefine in a derived
class. It is declared using the virtual keyword.
A pure virtual function is a function that has no implementation and is declared by
assigning 0. It has no body.
48) What is this pointer in C++?
The member functions of every object have a pointer named this, which points to the
object itself. The value of this is set to the address of the object for which it is called. It can be
used to access the data in the object it points to.
49) How do you allocate and deallocate memory in C++?
The new operator is used for memory allocation and deletes operator is used for memory
deallocation in C++.
50) What is a class?
The class is a user-defined data type. The class is declared with the keyword class. The class
contains the data members, and member functions whose access is defined by the three modifiers
are private, public and protected.
51) What are the various OOPs concepts in C++?
Class,Object,Inheritance,Encapsulation,Data binding, Abstraction,Polymorphism
52) Define namespace in C++.
The namespace is a logical division of the code which is designed to stop the naming
conflict.
53) Define token in C++.
A token in C++ can be a keyword, identifier, literal, constant and symbol.
54) How delete [] is different from delete?
Delete is used to release a unit of memory, delete[] is used to release an array.
55) What is an object?
The Object is the instance of a class. A class provides a blueprint for objects. So you can
create an object from a class.
56) What is the difference between an array and a list?
o An Array is a collection of homogeneous elements while a list is a collection of
heterogeneous elements.
o Array memory allocation is static and continuous while List memory allocation is
dynamic and random.
o In Array, users don't need to keep in track of next memory allocation while In the list, the
user has to keep in track of next location where memory is allocated.
57) What are the methods of exporting a function from a DLL?
There are two ways:
o By using the DLL's type library.
o Taking a reference to the function from the DLL instance.
58) What is an overflow error?
It is a type of arithmetical error. It happens when the result of an arithmetical operation
been greater than the actual space provided by the system.
59) What is overloading?
If we create two or more members having the same name but different in number or type of
parameter, it is known as C++ overloading.
60) What is function Overloading?
Function Overloading is defined as the process of having two or more function with the
same name, but different in parameters is known as function overloading in C++. In function
overloading, the function is redefined by using either different types of arguments or a different
number of arguments.
61) What is Operator Overloading?
Operator overloading is a compile-time polymorphism in which the operator is overloaded
to provide the special meaning to the user-defined data type. Operator overloading is used to
overload or redefines most of the operators available in C++.
62) What is function overriding?
If you inherit a class into a derived class and provide a definition for one of the base class's
function again inside the derived class, then this function is called overridden function, and this
mechanism is known as function overriding.
63) Explain this pointer?
This pointer holds the address of the current object.
64) What does Scope Resolution operator do?
A scope resolution operator(::) is used to define the member function outside the class.
65) What is a virtual destructor?
A virtual destructor in C++ is used in the base class so that the derived class object can
also be destroyed. A virtual destructor is declared by using the ~ tilde operator and then virtual
keyword before the constructor.
66) What is encapsulation?
The process of binding the data and the functions acting on the data together in an entity
(class) called as encapsulation.
67) What is abstraction?
Abstraction refers to hiding the internal implementation and exhibiting only the necessary
details.
68) Name the data type which can be used to store wide characters in C++.
wchar_t
69) What are/is the operator/operators used to access the class members?
Dot (.) and Arrow ( -> )
70) What is the data type to store the Boolean value?
bool, is the new primitive data type introduced in C++ language.
71) Name the default standard streams in C++.
cin, cout, cerr and clog.
72) Which access specifier/s can help to achive data hiding in C++?
Private & Protected
73) What is a container class?
A class containing at least one member variable of another class type in it is called so.
74) What is ‘std’?
Default namespace defined by C++.

75) Difference between equal to (==) and assignment operator(=)?


The equal to operator == checks whether two values are equal or not. If equal, then it’s
true; otherwise, it will return false.

The assignment operator = allots the value of the right-side expression to the left operand.

76) Discuss the difference between prefix and postfix?


In prefix (++i), first, it increments the value, and then it assigns the value to the expression.
In postfix (i++), it assigns the value to the expression, and then it increments the variable's
value.

77) What is l-value and r-value?


L-value appeared on the left side of the assignment operator
R-value appeared on the right side of the assignment operator.
78) What is a nested loop?
It is also a type of loop which runs within another loop is called nested loop.
79) What is the difference between while (0) and while (1)?
The term while is conditional based loop, While(0) means the condition of while loop is
false so it will never execute a particular section of the code inside the program. Whereas while(1)
is the opposite of while(0) and it will execute the particular section of code infinite times.
80) What is the use of rand() function in C ?
The rand() function in c is used to generate a random number.
81) What is the difference between declaration and definition?
The declaration tells the compiler that at some later point we plan to present the definition
of this declaration
The definition contains the actual implementation
82) What is polymorphism ?
Polymorphism means "many forms", and it occurs when we have many classes that are
related to each other by inheritance.
83) Diff between method overloading and method overriding

No. Method Overloading Method Overriding

1) Method overloading is used to increase the Method overriding is used to provide


readability of the program. the specific implementation of the
method that is already provided by its
super class.

2) Method overloading is performed within class. Method overriding occurs in two


classes that have IS-A (inheritance)
relationship.

3) In case of method overloading, parameter must be In case of method


different. overriding, parameter must be same.

4) Method overloading is the example of compile time Method overriding is the example
polymorphism. of run time polymorphism.

5) In java, method overloading can't be performed by Return type must be same or


changing return type of the method only. Return type covariant in method overriding.
can be same or different in method overloading. But
you must have to change the parameter.
83) Diference between a while loop and a do-while loop?
The while loop verifies the condition; if it’s true, then it iterates the loop till the condition
becomes false.
The do-while loop first iterates the loop body once, then it checks for the condition.
84)Which operator cannot be overloaded?
- ?: operator cannot be overloaded because it is not syntactically possible.
85) Define an Inline Function in C++
In order to reduce the function call overhead, C++ offers inline functions. As the
name suggests, an inline function is expanded in line when it is called.
86) Why do we need the Friend class and function?
Sometimes, there is a need for allowing a particular class to access private or protected
members of a class. The solution is a friend class, which can access the protected and private
members of the class in which it is declared as a friend.
87) What is the main difference between the keyword struct and class?
The keyword struct is used for resembling public members by default, while the keyword
class is used for resembling private members by default.
88) Define the Reference variable?
The reference variable in C++ is the name given to the existing variables. The variable
name and reference variable point share the same memory location in C++, which helps in
updating the original variable using the reference variable.
89) Types of error in C?
Errors in C programming are divided into two types. They are
I. Compile time errors
II. Run time errors
90) What are the jump statements in C ?
Jump statements are used to break the loops, continue the loop and jump to the required
statement
➢ Break
➢ Continue
➢ Goto
91) What are the translators in c ?
Assembler,compiler,Interpreter
92) How many keywords used in C?
32 keywords used in C(0-31)
93) What is extern in C?
extern is a keyword which is used to extends the visibility of C variable and C function
94) What are nodes and links?
Node: Any communicating device in a network is called a Node. Node is the point of
intersection in a network. It can send/receive data and information within a network. Examples of
the node can be computers, laptops, printers, servers, modems, etc.

Link: A link or edge refers to the connectivity between two nodes in the network. It
includes the type of connectivity (wired or wireless) between the nodes and protocols used for one
node to be able to communicate with the other.
95) What is the network topology?
Network topology is a physical layout of the network, connecting the different nodes using the
links. It depicts the connectivity between the computers, devices, cables, etc
96) Define the 7 different layers of the OSI Reference Model
Application, Presentation, Session, Transport, Network, Data Link, Physical
97) Define SDLC
SDLC is a process followed for a software project, within a software organization. It
consists of a detailed plan describing how to develop, maintain, replace and alter or enhance
specific software.
98) What are the stages of SDLC

➢ Planning and Requirement Analysis

➢ Defining Requirements

➢ Designing the Product Architecture

➢ Building or Developing the Product

➢ Testing the Product

➢ Deployment in the Market and Maintenance


99) What are the most important popular models in SDLC?

• Waterfall Model
• Iterative Model
• Spiral Model
• V-Model
• Big Bang Model
100) What is the DNS?

DNS is the Domain Name System. It is considered as the devices/services directory of the
Internet. It translates the domain names to their corresponding IPs.

101) what is the SDLC in software engineering?


Definition. The Software Development Life Cycle (SDLC) is a structured process that
enables the production of high-quality, low-cost software, in the shortest possible production
time. The goal of the SDLC is to produce superior software that meets and exceeds all customer
expectations and demands.

102) why is SDLC used?


Importance of SDLC

It provides an effective framework and method to develop software applications. It


helps in effectively planning before starting the actual development. SDLC allows developers to analyze
the requirements. It helps in reducing unnecessary costs during development.

103) what is SDLC explain with diagram?

SDLC is a process followed for a software project, within a software organization. It consists of a
detailed plan describing how to develop, maintain, replace and alter or enhance specific software. The life
cycle defines a methodology for improving the quality of software and the overall development process.

104) What is DBMS and what is its utility? Explain RDBMS with examples.

DBMS stands for database management system is a set of applications


or programs that enable users to create and maintain a database. DBMS provides a tool
or an interface for performing various operations such as inserting, deleting, updating,
etc. into a database. It is software that enables the storage of data more compactly and
securely as compared to a file-based system. A DBMS system helps a user to overcome
problems like data inconsistency, data redundancy, etc. in a database and makes it more
convenient and organized to use it.
RDBMS:

RDBMS stands for Relational Database Management System and was introduced in the 1970s to
access and store data more efficiently than DBMS. RDBMS stores data in the form of tables as compared
to DBMS which stores data as files. Storing data as rows and columns makes it easier to locate specific
values in the database and makes it more efficient as compared to DBMS.

Examples of popular RDBMS systems are MySQL, Oracle DB, etc.

105) Explain a few advantages of a DBMS.

• Data Sharing
• Integrity constraints
• Controlling redundancy in a database
• Data Independence
• Provides backup and recovery facility
• Data Security

106) Explain different languages present in DBMS.

Following are various languages present in DBMS:

• DDL(Data Definition Language): It contains commands which are required to define the
database.
E.g., CREATE, ALTER, DROP, TRUNCATE, RENAME, etc.
• DML(Data Manipulation Language): It contains commands which are required to manipulate
the data present in the database.
E.g., SELECT, UPDATE, INSERT, DELETE, etc.
• DCL(Data Control Language): It contains commands which are required to deal with the user
permissions and controls of the database system.
E.g., GRANT and REVOKE.
• TCL(Transaction Control Language): It contains commands which are required to deal with
the transaction of the database.
E.g., COMMIT, ROLLBACK, and SAVEPOINT.

107) What is meant by ACID properties in DBMS?

ACID stands for Atomicity, Consistency, Isolation, and Durability in a DBMS these are
those properties that ensure a safe and secure way of sharing data among multiple
users.
108) what is Data Warehousing?

The process of collecting, extracting, transforming, and loading data from multiple
sources and storing them in one database is known as Data Warehousing.

109) Explain different levels of data abstraction in a DBMS.

• Physical Level: it is the lowest level and is managed by DBMS. This level consists of data storage
descriptions and the details of this level are typically hidden from system admins, developers, and users.
• Conceptual or Logical level: it is the level on which developers and system admins work and it
determines what data is stored in the database and what is the relationship between the data points.
• External or View level: it is the level that describes only part of the database and hides the details of the
table schema and its physical storage from the user

110) Explain the difference between intension and extension in a database.

Following is the major difference between intension and extension in a database:

• Intension: Intension or popularly known as database schema is used to define the description
of the database and is specified during the design of the database and mostly remains
unchanged.
• Extension: Extension on the other hand is the measure of the number of tuples present in the
database at any given point in time. The extension of a database is also referred to as the
snapshot of the database and its value keeps changing as and when the tuples are created,
updated, or destroyed in a database.

111) Define TRUNCATE ?


TRUNCATE command: this command is needed to remove complete data from a table in a database. It
is like a DELETE command which has no WHERE clause.

112) What does ODBC in a database stand for ?


Open Database Connectivity

113) Explain different types of keys in a database

• Candidate Key: The candidate key represents a set of properties that can uniquely identify a table. Each
table may have multiple candidate keys. One key amongst all candidate keys can be chosen as a primary
key. In the below example since studentId and firstName can be considered as a Candidate Key since
they can uniquely identify every tuple.
• Super Key: The super key defines a set of attributes that can uniquely identify a tuple. Candidate key
and primary key are subsets of the super key, in other words, the super key is their superset.
• Primary Key: The primary key defines a set of attributes that are used to uniquely identify every
tuple. In the below example studentId and firstName are candidate keys and any one of them
can be chosen as a Primary Key. In the given example studentId is chosen as the primary key for
the student table.
• Unique Key: The unique key is very similar to the primary key except that primary keys don’t
allow NULL values in the column but unique keys allow them. So essentially unique keys are
primary keys with NULL values.
• Alternate Key: All the candidate keys which are not chosen as primary keys are considered as
alternate Keys. In the below example, firstname and lastname are alternate keys in the database.
• Foreign Key: The foreign key defines an attribute that can only take the values present in one
table common to the attribute present in another table. In the below example courseId from the
Student table is a foreign key to the Course table, as both, the tables contain courseId as one of
their attributes.
• Composite Key: A composite key refers to a combination of two or more columns that can
uniquely identify each tuple in a table. In the below example the studentId and firstname can be
grouped to uniquely identify every tuple in the table.

114) What is polymorphism?


Polymorphism is the ability of an object to take on multiple forms. Most commonly
polymorphism is used in OOP when a parent class reference is used to refer to a child
class object.

115) What is Embedded Systems Security?


An embedded system is a computing system built into a larger system, designed for dedicated

functions. It consists of a combination of hardware, software, and optionally mechanical parts.

Security is an important issue because of the roles of embedded systems in many mission and

safety-critical systems. Attacks on cyber systems are proved to cause physical

damages. Embedded security systems are generally found in pharma, industries, daily life needs

like home appliances, medical centers, or military components.

116) List out the Embedded Systems Security


Digital Camera
Washing machine
Calculator: It is a Hardware component used to calculate arithmetic operations with a
software component integrated with it.
ATM Machines
Telephones/Smart Phones
Traffic Signals

• Security Camera, Microwave Oven, Alarm Clock, Scanners, Refrigerators, Vending

Machines are also few examples of embedded security systems.

117) What is computer science?

Computer Science is the study of different programs that involves data and are
represented by multiple programs. Users can use algorithms, code, interact with
other people, and can manipulate digital information using Computer Science
knowledge. It helps one to do the computation and to design the software, to develop
different applications. Technology is used to solve the problems, and different subjects
are a microprocessor, programming languages, database, networks, and computer
software. A science that does not have any traditional scientific methods and uses only
technology to solve any problem is called Computer Science.

You might also like