Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
923 views
in Interview-Experiences by Expert (34,270 points) | 923 views

1 Answer

0 like 0 dislike

Question 1: How is C different from C++?
Answer: C++ can be said to be a superset of C. Major added features in C++ are Object-Oriented ProgrammingException Handling and rich C++ Library.
Learn about more differences and similarities between C and C++ from here.
 
Question 2: What is a static variable?
Answer: Static variables have a property of preserving their value even after they are out of their scope! Hence, static variables preserve their previous value in their previous scope and are not initialized again in the new scope.
 
Question 3: Are Variables in C static or Dynamic scoped?
Answer: Variables in C are always statically scoped. Visit How are variables scoped in C – Static or Dynamic? to learn more.
 
Question 4: Explain the four storage classes in C?
Answer: Storage Classes are used to describe the features of a variable/function. The four storage classes in C are:

 
Question 5: What do you mean by ‘pass by value’ and ‘pass by reference’?
Answer: In C we can pass the parameters in a function in two different ways:

More about parameter passing techniques in C/C++.
Practice problem on Parameter passing in C/C++.
 
Question 6: What do you mean by macros?
Answer: Macros are a piece of code in a program which is given some name. Whenever this name is encountered by the compiler, it replaces the name with the actual piece of code.
 
Question 7: What are structures in C?
Answer: A structure is a user-defined data type in C/C++. A structure creates a data type that can be used to group items of possibly different types into a single type.

Question 8: Write a program to find sum of elements in a given array.
Answer: Program to find sum of elements in a given array
 
Question 9: Write a program to reverse an array or string.
Answer: Program to reverse an array or string.
 
Question 10: Write output of following code:

 

 

 

#include <stdio.h> 

int main() 

    int x = 10, *y, **z; 

    

    y = &x; 

    z = &y; 

    printf("%d %d %d", *y, **z, *(*z)); 

    return 0; 

Output:

10 10 10

 
Questions related to OOPs:
 
Question 1: What are the main concepts of Object Oriented Programming?
Answer: Object-Oriented Programming or OOPs refers to languages that uses objects in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.
Main concepts of OOP are:

 
Question 2: What are classes and objects?
Answer: Classes and Objects are two major aspects of Object Oriented Programming:
Class: A class is a user defined blueprint or prototype from which objects are created. It represents the set of properties or methods that are common to all objects of one type.
Object: An Object is an identifiable entity with some characteristics and behavior. An Object is an instance of a Class. When a class is defined, no memory is allocated but when it is instantiated (i.e. an object is created) memory is allocated.
 
Question 3: What are different types of Inheritance?
Answer: Types of Inheritance:

 
Question 4: Differentiate Function Overloading and Function Overriding.
Answer: Function Overloading provides multiple definitions of the function by changing signature i.e changing the number of parameters, change the data type of parameters, return type doesn’t play any role whereas Function Overriding is the redefinition of base class function in its derived class with same signature i.e return type and parameters.
 
Question 5: Give a real-life based implementation of Polymorphism.
Answer: Real life example of polymorphism, a person at the same time can have different characteristic. Like a man at the same time is a father, a husband, an employee. So the same person posses different behavior in different situations. This is called polymorphism.
 
Question 6: What are Access modifiers?
Answer: Access modifiers are used to implement an important feature of Object-Oriented Programming known as Data Hiding. Access Modifiers or Access Specifiers in a class are used to set the accessibility of the class members. That is, it sets some restrictions on the class members not to get directly accessed by the outside functions.
 
 

by Expert (34,270 points)