Infosys Technical Interview Questions
Infosys Technical Interview Questions
a) C follows the procedural programming paradigm while C++ is a multi-paradigm language (procedural
as well as object oriented)
In case of C, importance is given to the steps or procedure of the program while C++ focuses on the
data rather than the process.
Also, it is easier to implement/edit the code in case of C++ for the same reason.
b) In case of C, the data is not secured while the data is secured (hidden) in C++
This difference is due to specific OOP features like Data Hiding which are not present in C.
c) C is a low-level language while C++ is a middle-level language
C is regarded as a low-level language (difficult interpretation & less user friendly) while C++ has
features of both low-level (concentration on what's going on in the machine hardware) & high-level
languages (concentration on the program itself) & hence is regarded as a middle-level language.
d) C uses the top-down approach while C++ uses the bottom-up approach
In case of C, the program is formulated step by step, each step is processed into detail while in C++,
the base elements are first formulated which then are linked together to give rise to larger systems.
e) C is function-driven while C++ is object-driven
Functions are the building blocks of a C program while objects are building blocks of a C++ program.
f) C++ supports function overloading while C does not
Overloading means two functions having the same name in the same program. This can be done only
in C++ with the help of Polymorphism (an OOP feature)
g) We can use functions inside structures in C++ but not in C.
In case of C++, functions can be used inside a structure while structures cannot contain functions in C.
h) The NAMESPACE feature in C++ is absent in case of C
C++ uses NAMESPACE which avoid name collisions. For instance, two students enrolled in the same
university cannot have the same roll number while two students in different universities might have the
same roll number. The universities are two different namespace & hence contain the same roll number
(identifier) but the same university (one namespace) cannot have two students with the same roll
number (identifier)
i) The standard input & output functions differ in the two languages
C uses scanf & printf while C++ uses cin>> & cout<< as their respective input & output functions
j) C++ allows the use of reference variables while C does not
Reference variables allow two variable names to point to the same memory location. We cannot use
these variables in C programming.
k) C++ supports Exception Handling while C does not.
C does not support it "formally" but it can always be implemented by other methods. Though you don't
have the framework to throw & catch exceptions as in C++.
Btree
It is made of branch nodes and leaf nodes. Branch nodes holds prefix key value along with the link to
the leaf node. The leaf node in turn contains the indexed value and rowed.
Bitmap
It simply consists of bits for every single distinct value. It uses a string of bits to quickly locate rows in a
table. Used to index low cardinality columns.
If heap size set too low then you will get "out of memory" errors. If you set it too high then
your system will hang or you will suffer poor performance because parts of the jvm will be
swapped in and out of memory. A rule of thumb is that you should not set this parameter
larger than about 80% of your free physical memory. On Windows XP machines you can
determine your free physical memory from the Performance tab of the Task Manager
application.
Boosting the heap size parameter will allow you to read in larger file-based projects. It will
also improve the performance of the database back-end since more memory is available for
caching.In Java Set the maximum heap size, using the -Xmx command-line option, to a
value that allows the application to run with 70% occupancy of the Java heap.The Java
heap occupancy often varies over time as the load applied to the application varies. For
applications where occupancy varies, set the maximum Java heap size so that there is 70%
occupancy at the highest point, and set the minimum heap size, using the -Xms command
line option, so that the Java heap is 40% occupied at its lowest memory usage. If these
values are set, the Java memory management algortihms can modify the heap size over
time according to the application load, while maintaining usage in the optimal area of
between 40% and 70% occupancy.
Both Arrays and Linked List can be used to store linear data of similar types.
Linked list provide dynamic size while the size of array is fixed, So we must know the upper limit on the
number of elements in advance.
Linked lists have following drawbacks:
1) Random access is not allowed. We have to access elements sequentially starting from the first node.
So we cannot do binary search with linked lists.
2) Extra memory space for a pointer is required with each element of the list.
3) Arrays have better cache locality that can make a pretty big difference in performance.
A candidate key acts as a unique key. A unique key can be a Primary key. A candidate key can be a
single column or combination of columns. Multiple candidate keys are allowed in a table.
Primary Key
To uniquely identify a row, Primary key is used.
A table allows only one Primary key
A Primary key can be a single column or combination of columns.
Foreign Key
A foreign key in a table is a key which refer another tables primary key . A primary key can be referred
by multiple foreign keys from other tables. It is not required for a primary key to be the reference of any
foreign keys. The interesting part is that a foreign key can refer back to the same table but to a different
Normalization is the process of efficiently organizing data in a database. There are two goals of the
normalization process: eliminating redundant data (for example, storing the same data in more than
one table) and ensuring data dependencies make sense (only storing related data in a table). Both of
these are worthy goals as they reduce the amount of space a database consumes and ensure that data
is logically stored.
Create relationships between these new tables and their predecessors through the use of foreign keys.
20.Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the
array. Optimize the boundary conditions.
void main()
{
int A[10]={'0','1','0','1','0','0','0','1','0','1','0','0'};
int x=0,y=A.length-1;
while(x<y){
if(!A[x])
x++;
else if(A[y])
y--;
if(A[x] && !A[y])//here we are checking that stating index is having 1 and last index having 0 than swap
values
A[x]=0,A[y]=1;
}
getch()
}
Abstraction is the basis for software development. Its through abstraction we define the essential
aspects of a system. The process of identifying the abstractions for a given system is called as
Modeling (or object modeling).
Three levels of data abstraction are:
1. Physical level : how the data is stored physically and where it is stored in database.
2. Logical level : what information or data is stored in the database. eg: Database administrator
3.View level : end users work on view level. if any amendment is made it can be saved by other name.
int i=10;
printf("%d%d%d",i,++i,i++);
Answer = 10 12 12