Infosys Interview Questions
Infosys Interview Questions
What is your strong point in terms of technical knowledge? Like JAVA, C, C++.
What is inheritance? What are the different types of inheritance?
What are any two the differences between C++ and Java?
How modularity is present in C++?
How abstraction and encapsulation complementary?
What is a linked list?
Differentiate between Arrays and Linked List.
What is the difference between array and pointer?
Some discussion about my hobbies. Which one is your favorite & why? What does it teach you?
Why are you not pursuing dance or basketball as your career? (I mentioned dance & basketball as my hobbies).
Tell me one real time situation where you have emerged as a Leader?
(CCET CSE student with 10th score 92%, 12th 90% and CGPA 7.94, having good extra-curricular activities record)
List out the areas in which data structures are applied extensively?
Difference between Class and Struct.
What is the difference between white box, black box, and gray box testing?
Tell us about the three levels of data abstraction? Which layer is at the user end?
Give different types of software model. Which model is best amongst them?
Write a program in C to swap two numbers without using a third variable.
Describe yourself.
Where would you like to work: software developing or software testing?
Why do you want to work at our company?
Why should we prefer you to other candidates?
What technical/functional areas interest you most? What would you be passionate about working on? Why?
(CCET CSE student with Xth score 87%, XIIth 85% and cgpa 7.65)
(A B.Engg – ECE student with 7.34 CGPA and having 87.5 % in 12th and 90 % in 10th standard.)
(ECE student, CGPA 7.58 in Graduation, 84.6% in 12th and 89.2% in 10th.)
What is a Zener diode? What is its use?
Difference between TCP and UDP.
Draw the circuit of a low pass filter? Where is its significance?
What is an IC? What is its importance?
Define VLSI technology.
Differentiate between LCD & LED screens.
What is the main function of a data link content monitor?
What are the communications lines best suited to interactive processing applications?
Introduce yourself and tell us something apart from the Resume.
Do you have an offer from any other organization?
Why do you want to work for us? Where do you see yourself in 8-10 years from now?
How would you describe your college life?
What are your strengths and weaknesses? What are you doing to overcome your weaknesses?
Mention a person who is your role model in life.
Where do you rate yourself (out of 10) as an engineer?
· Quantitative Ability
· Logical Ability
· Verbal Ability
From school days, I was not good at Maths and was a bit nervous to appear for Quantitative
Aptitude and Logical Reasoning. The only thing which saved me was that the prior practice
of questions with PrepInsta. I got a major idea of questions to be asked, and I got a firm belief
that I will clear the exam. My only strong zone was English and vocabulary. I relied on
verbal section a lot. After quickly completing the questions of previous two sections, I was
waiting to appear on the subject of my interest.
The HR Interview
The interviewer welcomed me with a pleasing smile and asked to sit. He started going
through my documents and asked me to tell about myself, and I did. I expected programming
questions and codes related stuff. But I got nothing of that sort. He brought a list of questions
my way that included, What do you think will be the future of IT industry? I answered AI.
Artificial Intelligence is one vertical which makes a long-lasting impact on the planet. There
were some more questions such as
· Why should Infosys hire you? How will you contribute to the growth of the company?
That was an extended week than a usual one when I had to wait for the final results. Finally,
on a Sunday evening, I received the mail from them saying that I was selected as the system
engineer trainee role.
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++.
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 table’s 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
column. This kind of foreign key is known as “self-referencing foreign key”.
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.
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</y){
A[x]=0,A[y]=1;
}
getch()
}
1. What is your strongest programming language (Java, ASP, C, C++, VB, HTML, C#, etc.)?
Point to remember: Before interview You should decide your Favorite programming language and be
prepared based on that question.
10.What is a class?
Class is a user-defined data type in C++. It can be created to solve a particular kind of problem. After
creation the user need not know the specifics of the working of a class.
Function overloading: C++ enables several functions of the same name to be defined, as long as these
functions have different sets of parameters (at least as far as their types are concerned). This capability
is called function overloading. When an overloaded function is called, the C++ compiler selects the
proper function by examining the number, types and order of the arguments in the call. Function
overloading is commonly used to create several functions of the same name that perform similar tasks
but on different data types.
Operator overloading allows existing C++ operators to be redefined so that they work on objects of
user-defined classes. Overloaded operators are syntactic sugar for equivalent function calls. They form
a pleasant facade that doesn't add anything fundamental to the language (but they can improve
understandability and reduce maintenance costs).
It permits code reusability. Reusability saves time in program development. It encourages the reuse of
proven and debugged high-quality software, thus reducing problem after a system becomes functional.
26. Tell something about deadlock and how can we prevent dead lock?
In an operating system, a deadlock is a situation which occurs when a process enters a waiting state
because a resource requested by it is being held by another waiting process, which in turn is waiting for
another resource. If a process is unable to change its state indefinitely because the resources
requested by it are being used by other waiting process, then the system is said to be in a deadlock.
Mutual Exclusion: At least one resource must be non-shareable.[1] Only one process can use the
resource at any given instant of time.
Hold and Wait or Resource Holding: A process is currently holding at least one resource and requesting
additional resources which are being held by other processes.
No Preemption: The operating system must not de-allocate resources once they have been allocated;
they must be released by the holding process voluntarily.
Circular Wait: A process must be waiting for a resource which is being held by another process, which
in turn is waiting for the first process to release the resource. In general, there is a set of waiting
processes, P = {P1, P2, ..., PN}, such that P1 is waiting for a resource held by P2, P2 is waiting for a
resource held by P3 and so on till PN is waiting for a resource held by P1.[1][7]
Thus prevention of deadlock is possible by ensuring that at least one of the four conditions cannot hold.
27. What is Insertion sort, selection sort, bubble sort( basic differences among the functionality
of the three sorts and not the exact algorithms)
A doctor sees (abstracts) the person as patient. The doctor is interested in name, height, weight, age,
blood group, previous or existing diseases etc of a person
An employer sees (abstracts) a person as Employee. The employer is interested in name, age, health,
degree of study, work experience etc of a person.
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.
33.Which header file should you include if you are to develop a function which can accept
variable number of arguments?
stdarg.h
35.What is debugger?
A debugger or debugging tool is a computer program that is used to test and debug other programs
36. Const char *p , char const *p What is the difference between the above two?
1) const char *p - Pointer to a Constant char ('p' isn't modifiable but the pointer is)
2) char const *p - Also pointer to a constant Char
However if you had something like:
char * const p - This declares 'p' to be a constant pointer to an char. (Char p is modifiable but the
pointer isn't)
38.Explain the difference between 'operator new' and the 'new' operator?
The difference between the two is that operator new just allocates raw memory, nothing
else. The new operator starts by using operator new to allocate memory, but then it invokes
the constructor for the right type of object, so the result is a real live object created in that
memory. If that object contains any other objects (either embedded or as base classes)
those constructors as invoked as well.
o With data warehousing, you can provide a common data model for different interest areas regardless
of data's source. In this way, it becomes easier to report and analyze information.
o Many inconsistencies are identified and resolved before loading of information in data warehousing.
This makes the reporting and analyzing process simpler.
o The best part of data warehousing is that the information is under the control of users, so that in case
the system gets purged over time, information can be easily and safely stored for longer time period.
o Because of being different from operational systems, a data warehouse helps in retrieving data
without slowing down the operational system.
o Data warehousing enhances the value of operational business applications and customer relationship
management systems.
o Data warehousing also leads to proper functioning of support system applications like trend reports,
exception reports and the actual performance analyzing reports.
Data mining is a powerful new technology to extract data for analysis.
43.Explain recursive function & what is the data structures used to perform recursion?
a) A recursive function is a function which calls itself.
b) The speed of a recursive program is slower because of stack overheads. (This attribute is evident if
you run above C program.)
c) A recursive function must have recursive conditions, terminating conditions, and recursive
expressions.
Stack data structure . Because of its LIFO (Last In First Out) property it remembers its caller so knows
whom to return when the function has to return. Recursion makes use of system stack for storing the
return addresses of the function calls. Every recursive function has its equivalent iterative (non-
recursive) function. Even when such equivalent iterative procedures are written, explicit stack is to be
used.
46.What is an interrupt?
Interrupt is an asynchronous signal informing a program that an event has occurred. When a program
receives an interrupt signal, it takes a specified action.
Garbage collection is the systematic recovery of pooled computer storage that is being used by a
program when that program no longer needs the storage. This frees the storage for use by other
programs
(or processes within a program). It also ensures that a program using increasing amounts of pooled
storage does not reach its quota (in which case it may no longer be able to function).
if(item == arr[middle])
{
return(middle);
}
if(item > arr[middle])
{
left = middle+1;
}
else
{
right = middle-1;
}
}
return(-1);
}
53.What is Cryptography?
Cryptography is the science of enabling secure communications between a sender and one
or more recipients. This is achieved by the sender scrambling a message (with a computer
program and a secret key) and leaving the recipient to unscramble the message (with the
same computer program and a key, which may or may not be the same as the sender's
key).
There are two types of cryptography: Secret/Symmetric Key Cryptography and Public Key
Cryptography
54.What is encryption?
Encryption is the transformation of information from readable form into some unreadable form.
55.What is decryption?
Decryption is the reverse of encryption; it's the transformation of encrypted data back into some
intelligible form.
56.What exactly is a digital signature?
Just as a handwritten signature is affixed to a printed letter for verification that the letter originated from
its purported sender, digital signature performs the same task for an electronic message. A digital
signature is an encrypted version of a message digest, attached together with a message.
Object is a software bundle of variables and related methods. Objects have state and behavior.
What do you mean by inheritance?
Inheritance is the process of creating new classes, called derived classes, from existing classes or
base classes. The derived class inherits all the capabilities of the base class, but can add
embellishments and refinements of its own.
What is polymorphism?
Polymorphism is the idea that a base class can be inherited by several classes. A base class pointer
can point to its child class and a base class array can store different child class objects.
44. What is a scope resolution operator?
A scope resolution operator (::), can be used to define the member functions of a class outside the
class.
Anything wrong with this code?
T *p = new T[10];
delete p;
Everything is correct, Only the first element of the array will be deleted”, The entire array will be deleted,
but only the first element destructor will be called.
What is Boyce Codd Normal form?
A relation schema R is in BCNF with respect to a set F of functional dependencies if for all functional
dependencies in F+ of the form a-> , where a and b is a subset of R, at least one of the following holds:
* a- > b is a trivial functional dependency (b is a subset of a)
* a is a superkey for schema R
How do you find out if a linked-list has an end? (i.e. the list is not a cycle)
You can find out by using 2 pointers. One of them goes 2 nodes each time. The second one goes at 1
nodes each time. If there is a cycle, the one that goes 2 nodes each time will eventually meet the one
that goes slower.
If that is the case, then you will know the linked-list is a cycle.
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.
Function overloading: C++ enables several functions of the same name to be defined, as long as these
functions have different sets of parameters (at least as far as their types are concerned). This capability
is called function overloading. When an overloaded function is called, the C++ compiler selects the
proper function by examining the number, types and order of the arguments in the call. Function
overloading is commonly used to create several functions of the same name that perform similar tasks
but on different data types.
Operator overloading allows existing C++ operators to be redefined so that they work on objects of
user-defined classes. Overloaded operators are syntactic sugar for equivalent function calls. They form
a pleasant facade that doesn't add anything fundamental to the language (but they can improve
understandability and reduce maintenance costs).
The declaration tells the compiler that at some later point we plan to present the definition of this
declaration.
E.g.: void stars () //function declaration
The definition contains the actual implementation.
E.g.: void stars () // declarator
{
for(int j=10; j > =0; j--) //function body
cout << *;
cout <<>
void reverselist(void)
{
if(head==0)
return;
if(head->next==0)
return;
if(head->next==tail)
{
head->next = 0;
tail->next = head;
}
else
{
node* pre = head;
node* cur = head->next;
node* curnext = cur->next;
head->next = 0;
cur-> next = head;
for(; curnext!=0; )
{
cur->next = pre;
pre = cur;
cur = curnext;
curnext = curnext->next;
}
curnext->next = cur;
}
}
The idea behind inline functions is to insert the code of a called function at the point where the function
is called. If done carefully, this can improve the application's performance in exchange for increased
compile time and possibly (but not always) an increase in the size of the generated binary executables.
Write a program that ask for user input from 5 to 9 then calculate the average
#include "iostream.h"
int main() {
int MAX = 4;
int total = 0;
int average;
int numb;
for (int i=0; icout << "Please enter your input between 5 and 9: ";
cin >> numb;
while ( numb<5>9) {
cout << "Invalid input, please re-enter: ";
cin >> numb;
}
total = total + numb;
}
average = total/MAX;
cout << "The average number is: " <<>return 0;
}
Global variables: are variables which are declared above the main( ) function. These variables are
accessible throughout the program. They can be accessed by all the functions in the program. Their
default value is zero.
What is scope & storage allocation of static, local and register variables? Explain with an
example.
Register variables: belong to the register storage class and are stored in the CPU registers. The scope
of the register variables is local to the block in which the variables are defined. The variables which are
used for more
number of times in a program are declared as register variables for faster access.
Example: loop counter variables.
register int y=6;
Static variables: Memory is allocated at the beginning of the program execution and it is reallocated
only after the program terminates. The scope of the static variables is local to the block in which the
variables are defined.
Example:
#include
void decrement(){
static int a=5;
a--;
printf("Value of a:%d\n", a);
}
int main(){
decrement();
return 0;
}
Local variables: are variables which are declared within any function or a block. They can be accessed
only by function or block in which they are declared. Their default value is a garbage value.
What are the advantages of using unions?
Union is a collection of data items of different data types.
It can hold data of only one member at a time though it has members of different data types.
If a union has two members of different data types, they are allocated the same memory. The memory
allocated is equal to maximum size of the members. The data is interpreted in bytes depending on
which member is being accessed.
Example:
union pen {
char name;
float point;
};
Here name and point are union members. Out of these two variables, ‘point’ is larger variable which is
of float data type and it would need 4 bytes of memory. Therefore 4 bytes space is allocated for both
the variables. Both the variables have the same memory location. They are accessed according to their
type.
Union is efficient when members of it are not required to be accessed at the same time.
If a list is circular, at some point pointer2 will wrap around and be either at the item just before pointer1,
or the item before that. Either way, it’s either 1 or 2 jumps until they meet.
What is virtual constructors/destructors?
Virtual destructors: If an object (with a non-virtual destructor) is destroyed explicitly by applying the
delete operator to a base-class pointer to the object, the base-class destructor function (matching the
pointer type) is called on the object.
There is a simple solution to this problem – declare a virtual base-class destructor. This makes all
derived-class destructors virtual even though they don’t have the same name as the base-class
destructor. Now, if the object in the hierarchy is destroyed explicitly by applying the delete operator to a
base-class pointer to a derived-class object, the destructor for the appropriate class is called.
Virtual constructor: Constructors cannot be virtual. Declaring a constructor as a virtual function is a
syntax error.
What are the advantages of inheritance?
• It permits code reusability.
• Reusability saves time in program development.
• It encourages the reuse of proven and debugged high-quality software, thus reducing problem after a
system becomes functional.
Does c++ support multilevel and multiple inheritance?
Yes.
What is the difference between an ARRAY and a LIST?
Array is collection of homogeneous elements.
List is collection of heterogeneous elements.
Array: User need not have to keep in track of next memory allocation.
List: User has to keep in Track of next location where memory is allocated.
Array uses direct access of stored members, list uses sequencial access for members.
What is a template?
Templates allow to create generic functions that admit any data type as parameters and return value
without having to overload the function with all the possible data types. Until certain point they fulfill the
functionality of a macro. Its prototype is any of the two following ones:
What is the difference between class and structure?
Structure: Initially (in C) a structure was used to bundle different type of data types together to perform
a particular functionality. But C++ extended the structure to contain functions also. The major difference
is that all declarations inside a structure are by default public.
Class: Class is a successor of Structure. By default all the members inside the class are private.
What is encapsulation?
Packaging an object’s variables within its methods is called encapsulation.
What is a COPY CONSTRUCTOR and when is it called?
A copy constructor is a method that accepts an object of the same class and copies it’s data members
to the object on the left part of assignment:
class Point2D{
int x; int y;
public int color;
protected bool pinned;
public Point2D() : x(0) , y(0) {} //default (no argument) constructor
public Point2D( const Point2D & ) ;
};
Point2D::Point2D( const Point2D & p )
{
this->x = p.x;
this->y = p.y;
this->color = p.color;
this->pinned = p.pinned;
}
main(){yu
Point2D MyPoint;
MyPoint.color = 345;
Point2D AnotherPoint = Point2D( MyPoint ); // now AnotherPoint has color = 345
Program: To calculate the factorial value using recursion.
Program: To calculate the factorial value using recursion.
#include
int fact(int n);
int main() {
int x, i;
printf("Enter a value for x: \n");
scanf("%d", &x);
i = fact(x);
printf("\nFactorial of %d is %d", x, i);
return 0;
}
int fact(int n) {
/* n=0 indicates a terminating condition */
if (n <= 0) {
return (1);
} else {
/* function calling itself */
return (n * fact(n - 1));
/*n*fact(n-1) is a recursive expression */
}
}
Output:
Enter a value for x:4
Factorial of 4 is 24
swap 2 numbers without using third variable?
#include
void main()
{
int a,b;
printf("enter number1: ie a");
scanf("%d",a);
printf("enter number2:ie b ");
scanf("%d",b);
printf(value of a and b before swapping is a=%d,b=%d"a,b);
a=a+b;
b=a-b;
a=a-b;
printf(value of a and b after swapping is a=%d,b=%d"a,b);
}
Write a C++ Program to check whether a number is prime number or not?
#include
#include
void main()
{
clrscr();
int n,i,flag=1;
cout<<"Enter any number:";
cin>>n;
for(i=2;i<=n/2;++i)
{
if(n%i==0)
{
flag=0;
break;
}
}
if(flag)
cout<<"\n"<<n<<" is="" a="" prime="" number";
else
cout<<"\n"<<n<<" is="" not="" a="" prime="" number";
getch();
}</n<<"></n<<">
Write a program in c to replace any vowel in a string with z?
// Replace all vowels in str with 'z'
void replaceWithZ(char* str) {
int i = 0;
while(str[i] != 'z') {
if(isVowel(str[i])) {
str[i] = 'z';
}
++i;
}
}
// Returns 1 if ch is a vowel, 0 otherwise
int isVowel(const char ch) {
switch(ch) {
case 'a':case 'A':
case 'e':case 'E':
case 'i':case 'I':
case 'o':case 'O':
case 'u':case 'U':
return 1;
}
return 0;
}
// Sample call
int main() {
char str[] = "HELLO";
printf("%s\n", str);
replaceWithZ(str);
printf("%s\n", str);
return 0;
}
To act as interface between hardware and users, an operating system must be able perform the
following functions:
1. Enabling startup application programs. Thus, the operating system must have:
- A text editor
- A translator
- An editor of links
3. Facilities for data compression, sorting, mixing, cataloging and maintenance of libraries, through
utility programs available.
4. Plan implementation works according to certain criteria, for efficient use of central processing unit.
A UNIQUE constraint is similar to PRIMARY key, but you can have more than one UNIQUE constraint
per table. Contrary to PRIMARY key UNIQUE constraints can accept NULL but just once. If the
constraint is defined in a combination of fields, then every field can accept NULL and can have some
values on them, as long as the combination values is unique.
Is XML case-sensitive?
XML is case sensitive when uppercase and lowercase characters are treated differently.
Element type names, Attribute names, Attribute values, All general and parameter entity names, and
data content (text), are case-sensitive.
What is a Null object?
It is an object of some class whose purpose is to indicate that a real object of that class does not exist.
One common use for a null object is a return value from a member function that is supposed to return
an object with some specified properties but cannot find such an object.
What is the property of class?
A property is a member that provides access to an attribute of an object or a class. Examples of
properties include the length of a string, the size of a font, the caption of a window, the name of a
customer, and so on.
Does a class inherit the constructors of its super class?
A class does not inherit constructors from any of its super classes.
If a class is declared without any access modifiers, where may the class be accessed?
A class that is declared without any access modifiers is said to have package access. This means that
the class can only be accessed by other classes andinterfaces that are defined within the same
package
Post-Condition: A condition that should return true before returning from an invoked function. In order to
use a function correctly a post condition should return true. Taking a stack as an example, is empty ()
must necessarily be true after pushing the element into the stack when an element is pushed. The
function is empty () is a post condition.
How can you sort the elements of the array in descending order?
Syntax
B = sort(A)
B = sort(A,dim)
B = sort(...,mode)
[B,IX] = sort(A,...)
Description
B = sort(A) sorts the elements along different dimensions of an array, and arranges those elements in
ascending order.
Multidimensional array Sorts A along the first non-singleton dimension, and returns an
array of sorted vectors.
Cell array of strings Sorts the strings in ascending ASCII dictionary order, and returns a
vector cell array of strings. The sort is case-sensitive; uppercase letters appear in the output
before lowercase. You cannot use the dim or mode options with a cell
array.
Sort - Sort array elements in ascending or descending order
Integer, floating-point, logical, and character arrays are permitted. Floating-point arrays can
be complex. For elements of A with identical values, the order of these elements is
preserved in the sorted list. When A is complex, the elements are sorted by magnitude, i.e.,
abs(A), and where magnitudes are equal, further sorted by phase angle, i.e., angle(A), on
the interval [??, ?]. If A includes any NaN elements, sort places these at the high end.
B = sort(A,dim) sorts the elements along the dimension of A specified by a scalar dim.
B = sort(...,mode) sorts the elements in the specified direction, depending on the value of mode.
'ascend'
Ascending order (default)
'descend'
Descending order
[B,IX] = sort(A,...) also returns an array of indices IX, where size(IX) == size(A). If A is a vector, B =
A(IX). If A is an m-by-n matrix, then each column of IX is a permutation vector of the corresponding
column of A, such that
for j = 1:n
B(:,j) = A(IX(:,j),j);
end
If A has repeated elements of equal value, the returned indices preserve the original ordering.
Example:Sort horizontal vector A:
sort(A)
ans =5 6 10 23 45 78 100
What is DOM?
The Document Object Model (DOM) is a cross-platform and language-independent
convention for representing and interacting with objects in HTML, XHTML and XML
documents.[1] Objects in the DOM tree may be addressed and manipulated by using
methods on the objects. The public interface of a DOM is specified in its application
programming interface (API).
a) In overloading, there is a relationship between methods available in the same class whereas in
overriding, there is relationship between a superclass method and subclass method.
b) Overloading does not block inheritance from the superclass whereas overriding blocks inheritance
from the superclass.
c) In overloading, separate methods share the same name whereas in overriding, subclass method
replaces the superclass.
d) Overloading must have different method signatures whereas overriding must have same signature.
. - dot operator
Sizeof() - operator
What is polymorphism?
In programming languages, polymorphism means that some code or operations or objects
behave differently in different contexts.
Typically, when the term polymorphism is used with C++, however, it refers to using virtual methods,
which we'll discuss shortly.
What are the differences between a C++ struct and C++ class?
The default member and base class access specifiers are different.
The C++ struct has all the features of the class. The only differences are that a struct defaults to public
member access and public base class inheritance, and a class defaults to the private access specifier
and private base class inheritance.
main()
{
char a[100], b[100];
if( strcmp(a,b) == 0 )
printf("Entered string is a palindrome.\n");
else
printf("Entered string is not a palindrome.\n");
return 0;
}
Palindrome number in c
#include
main()
{
int n, reverse = 0, temp;
temp = n;
while( temp != 0 )
{
reverse = reverse * 10;
reverse = reverse + temp%10;
temp = temp/10;
}
if ( n == reverse )
printf("%d is a palindrome number.\n", n);
else
printf("%d is not a palindrome number.\n", n);
return 0;
}
#include
#include
main()
{
char arr[100];
return 0;
}
#include
main()
{
int n, first = 0, second = 1, next, c;
return 0;
}
#include
int Fibonacci(int);
main()
{
int n, i = 0, c;
scanf("%d",&n);
printf("Fibonacci series\n");
return 0;
}
int Fibonacci(int n)
{
if ( n == 0 )
return 0;
else if ( n == 1 )
return 1;
else
return ( Fibonacci(n-1) + Fibonacci(n-2) );
}
#include
main()
{
long first, second, sum;
printf("%ld\n", sum);
return 0;
}
result = a + b;
return result;
}
Your favorite subject?
What is C language?
The C programming language is a standardized programming language developed in the early 1970s
by Ken Thompson and Dennis Ritchie for use on the UNIX operating system. It has since spread to
many other operating systems, and is one of the most widely used programming languages. C is prized
for its efficiency, and is the most popular programming language for writing system software, though it
is also used for writing applications. ...
Google-Some of the Google applications are also written in C++, including Google file system and
Google Chromium.
Symbian OS- is also developed using C++. This is one of the most widespread OS’s for cellular
phones.
Apple – OS X -Few parts of apple OS X are written in C++ programming language. Also few application
for iPod are written in C++.
Microsoft-Most of the big applications like Windows 95, 98, Me, 200 and XP are also written in C++.
Also Microsoft Office, Internet Explorer and Visual Studio are written in Visual C++.
What is an object?
Object is a software bundle of variables and related methods. Objects have state and behavior
What is a class?
Class is a user-defined data type in C++. It can be created to solve a particular kind of problem. After
creation the user need not know the specifics of the working of a class.
1. What is a modifier?
A modifier, also called a modifying function is a member function that changes the value of at least one
data member. In other words, an operation that modifies the state of an object. Modifiers are also
known as ‘mutators’.
5. Define namespace.
It is a feature in C++ to minimize name collisions in the global name space. This namespace keyword
assigns a distinct name to a library that allows other libraries to use the same identifier names without
creating any name collisions. Furthermore, the compiler uses the namespace signature for
differentiating the definitions.
What is data structure?
A data structure is a way of organizing data that considers not only the items stored, but also their
relationship to each other. Advance knowledge about the relationship between data items allows
designing of efficient algorithms for the manipulation of data
Can you list out the areas in which data structures are applied extensively?
Compiler Design,
Operating System,
Numerical Analysis,
Graphics,
Artificial Intelligence,
Simulation
C++ supports overloading concepts like operator overloading and function overloading
C does not support namespaces concept
**Simplicity
**modularity:
**modifiability
**extensibility
**maintainability
**re-usability
simplicity: software objects model real world objects, so the complexity is reduced and the program
structure is very clear;
modularity: each object forms a separate entity whose internal workings are decoupled from
other parts of the system;
modifiability: it is easy to make minor changes in the data representation or the procedures in an OO
program. Changes inside a class do not affect any other part of a program, since the only public
interface that the external world has to a class is through the use of methods;
extensibility: adding new features or responding to changing operating environments can be solved by
introducing a few new objects and modifying some existing ones;
maintainability: objects can be maintained separately, making locating and fixing problems
easier;
In C, malloc, calloc and realloc are used to allocate memory dynamically. In C++, new(), is usually used
to allocate objects.
List advantages and disadvantages of dynamic memory allocation vs. static memory
allocation.?
Advantages:
Memory is allocated on an as-needed basis. This helps remove the inefficiencies inherent to static
memory allocation (when the amount of memory needed is not known at compile time and one has to
make a guess).
Disadvantages:
Dynamic memory allocation is slower than static memory allocation. This is because dynamic memory
allocation happens in the heap area.
Dynamic memory needs to be carefully deleted after use. They are created in non-contiguous area of
memory segment.
Dynamic memory allocation causes contention between threads, so it degrades performance when it
happens in a thread.
Memory fragmentation.
What is Java?
Java is an object-oriented programming language developed initially by James Gosling and colleagues
at Sun Microsystems. The language, initially called Oak (named after the oak trees outside Gosling's
office), was intended to replace C++, although the feature set better resembles that of Objective C.
Java should not be confused with JavaScript, which shares only the name and a similar C-like syntax.
Sun Microsystems currently maintains and updates Java regularly.
Yes, all functions in Java are virtual by default. This is actually a pseudo trick question because the
word "virtual" is not part of the naming convention in Java (as it is in C++, C-sharp and VB.NET), so
this
would be a foreign concept for someone who has only coded in Java. Virtual functions or virtual
methods are functions or methods that will be redefined in derived classes.
What is a transient variable in Java?
A transient variable is a variable that may not be serialized. If you don't want some field to be serialized,
you can mark that field transient or static.
What is thread?
A thread is an independent path of execution in a system.
What is multi-threading?
Multi-threading means various threads that run in a system.
pointers that do not point to a valid object of the appropriate type. Dangling pointers arise when an
object is deleted or deallocated, without modifying the value of the pointer, so that the pointer still points
to the memory location of the deallocated memory. As the system may reallocate the previously freed
memory to another process, if the original program then dereferences the (now) dangling pointer,
unpredictable behavior may result, as the memory may now contain completely different data. This is
especially the case if the program writes data to memory pointed by a dangling pointer, as silent
corruption of unrelated data may result, leading to subtle bugs that can be extremely difficult to find, or
cause segmentation faults (*NIX) or general protection faults (Windows).
What are the advantages and disadvantages of B-star trees over Binary trees.?
The major difference between B-tree and binary tres is that B-tree is a external data structure and
binary tree is a main memory data structure. The computational complexity of binary tree is counted by
the number of comparison operations at each node, while the computational complexity of B-tree is
determined by the disk I/O, that is, the number of node that will be loaded from disk to main memory.
The comparision of the different values in one node is not counted.
Answer: 5,20,1
1. What is C language?
The C programming language is a standardized programming language developed in the early 1970s by Ken
Thompson and Dennis Ritchie for use on the UNIX operating system. It has since spread to many other operating
systems, and is one of the most widely used programming languages. C is prized for its efficiency, and is the most
popular programming language for writing system software, though it is also used for writing applications.
Variables with block scope, and with static specifier have static scope. Global variables (i.e, file scope) with or without
the the static specifier also have static scope. Memory obtained from calls to malloc(), alloc() or realloc() belongs to
allocated storage class.
4. What is hashing?
To hash means to grind up, and that’s essentially what hashing is all about. The heart of a hashing algorithm is a hash
function that takes your nice, neat data and grinds it into some random-looking integer.
The idea behind hashing is that some data either has no inherent ordering (such as images) or is expensive to
compare (such as images). If the data has no inherent ordering, you can’t perform comparison searches.
13. Can you tell me how to check whether a linked list is circular?
Create two pointers, and set both to the start of the list. Update each as follows:
while (pointer1) {
pointer1 = pointer1->next;
pointer2 = pointer2->next;
if (pointer2) pointer2=pointer2->next;
if (pointer1 == pointer2) {
print ("circular");
}
}
If a list is circular, at some point pointer2 will wrap around and be either at the item just before pointer1, or the item
before that. Either way, its either 1 or 2 jumps until they meet.
16. Write down the equivalent pointer expression for referring the same element a[i][j][k][l] ?
a[i] == *(a+i)
a[i][j] == *(*(a+i)+j)
a[i][j][k] == *(*(*(a+i)+j)+k)
a[i][j][k][l] == *(*(*(*(a+i)+j)+k)+l)
17. Which bit wise operator is suitable for checking whether a particular bit is on or off?
The bitwise AND operator. Here is an example:
enum {
KBit0 = 1,
KBit1,
…
KBit31,
};
if ( some_int & KBit24 )
printf ( “Bit number 24 is ON\n” );
else
printf ( “Bit number 24 is OFF\n” );
18. Which bit wise operator is suitable for turning off a particular bit in a number?
The bitwise AND operator, again. In the following code snippet, the bit number 24 is reset to zero.
some_int = some_int & ~KBit24;
19. Which bit wise operator is suitable for putting on a particular bit in a number?
The bitwise OR operator. In the following code snippet, the bit number 24 is turned ON:
some_int = some_int | KBit24;
20. Does there exist any other function which can be used to convert an integer or a float to a string?
Some implementations provide a nonstandard function called itoa(), which converts an integer to string.
#include
char *itoa(int value, char *string, int radix);
DESCRIPTION
The itoa() function constructs a string representation of an integer.
PARAMETERS
value: Is the integer to be converted to string representation.
string: Points to the buffer that is to hold resulting string.
The resulting string may be as long as seventeen bytes.
radix: Is the base of the number; must be in the range 2 - 36.
A portable solution exists. One can use sprintf():
char s[SOME_CONST];
int i = 10;
float f = 10.20;
sprintf ( s, “%d %f\n”, i, f );
21. Why does malloc(0) return valid memory address ? What's the use?
malloc(0) does not return a non-NULL under every implementation. An implementation is free to behave in a manner
it finds suitable, if the allocation size requested is zero. The implmentation may choose any of the following actions:
* A null pointer is returned.
* The behavior is same as if a space of non-zero size was requested. In this case, the usage of return value yields to
undefined-behavior.
Notice, however, that if the implementation returns a non-NULL value for a request of a zero-length space, a pointer
to object of ZERO length is returned! Think, how an object of zero size should be represented
For implementations that return non-NULL values, a typical usage is as follows:
void
func ( void )
{
int *p; /* p is a one-dimensional array, whose size will vary during the the lifetime of the program */
size_t c;
p = malloc(0); /* initial allocation */
if (!p)
{
perror (”FAILURE” );
return;
}
/* … */
while (1)
{
c = (size_t) … ; /* Calculate allocation size */
p = realloc ( p, c * sizeof *p );
/* use p, or break from the loop */
/* … */
}
return;
}
Notice that this program is not portable, since an implementation is free to return NULL for a malloc(0) request, as the
C Standard does not support zero-sized objects.
24. What is the benefit of using an enum rather than a #define constant?
The use of an enumeration constant (enum) has many advantages over using the traditional symbolic constant style of
#define. These advantages include a lower maintenance requirement, improved program readability, and better
debugging capability.
1) The first advantage is that enumerated constants are generated automatically by the compiler. Conversely,
symbolic constants must be manually assigned values by the programmer.
2) Another advantage of using the enumeration constant method is that your programs are more readable and thus
can be understood better by others who might have to update your program later.
3) A third advantage to using enumeration constant
1. What is database?
A database is a collection of information that is organized. So that it can easily be accessed, managed, and updated.
2. What is DBMS?
DBMS stands for Database Management System. It is a collection of programs that enables user to create and maintain a
database.
I. Redundancy is controlled.
5. What is normalization?
It is a process of analysing the given relation schemas based on their Functional Dependencies (FDs) and primary key to
achieve the properties
(1).Minimizing redundancy, (2). Minimizing insertion, deletion and update anomalies.
This data model is based on real world that consists of basic objects called entities and of relationship among these objects.
Entities are described in a database by a set of attributes.
This model is based on collection of objects. An object contains values stored in instance variables with in the object. An object
also contains bodies of code that operate on the object. These bodies of code are called methods. Objects that contain same
types of values and the same methods are grouped together into classes.
9. What is an Entity?
An entity is a thing or object of importance about which data must be captured.
A data base schema is specifies by a set of definitions expressed by a special language called DDL.
11. What is DML (Data Manipulation Language)?
This language that enable user to access or manipulate data as organised by appropriate data model. Procedural DML or Low
level: DML requires a user to specify what data are needed and how to get those data. Non-Procedural DML or High level: DML
requires a user to specify what data are needed without specifying how to get those data
It translates DML statements in a query language into low-level instruction that the query evaluation engine can understand.
Functional Dependency is the starting point of normalization. Functional Dependency exists when a relation between two
attributes allows you to uniquely determine the corresponding attribute’s value.
The first normal form or 1NF is the first and the simplest type of normalization that can be implemented in a database. The
main aims of 1NF are to:
2. Create separate tables for each group of related data and identify each row with a unique column (the primary key).
A functional dependency X Y is full functional dependency if removal of any attribute A from X means that the dependency
does not hold any more.
A relation schema R is in 2NF if it is in 1NF and every non-prime attribute A in R is fully functionally dependent on primary key.
A relation is in third normal form if it is in Second Normal Form and there are no functional (transitive) dependencies between
two (or more) non-primary key attributes.
A table is in Boyce-Codd normal form (BCNF) if and only if it is in 3NF and every determinant is a candidate key.
Fourth normal form requires that a table be BCNF and contain no multi-valued dependencies.
A table is in fifth normal form (5NF) or Project-Join Normal Form (PJNF) if it is in 4NF and it cannot have a lossless
decomposition into any number of smaller tables.
A query with respect to DBMS relates to user commands that are used to interact with a data base.
The phase that identifies an efficient execution plan for evaluating a query that has the least estimated cost is referred to as
query optimization.
Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and
indices in tables.
DBMS provides a systematic and organized way of storing, managing and retrieving from collection of logically related
information. RDBMS also provides what DBMS provides but above that it provides relationship integrity.
SQL stands for Structured Query Language. SQL is an ANSI (American National Standards Institute) standard computer
language for accessing and manipulating database systems. SQL statements are used to retrieve and update data in a
database.
A stored procedure is a named group of SQL statements that have been previously created and stored in the server database.
A view may be a subset of the database or it may contain virtual data that is derived from the database files but is not
explicitly stored.
A trigger is a SQL procedure that initiates an action when an event (INSERT, DELETE or UPDATE) occurs.
Extension -It is the number of tuples present in a table at any instance. This is time dependent.
Intension -It is a constant value that gives the name, structure of table and the constraints laid on it.
Atomicity-Atomicity states that database modifications must follow an “all or nothing” rule. Each transaction is said to be
“atomic.” If one part of the transaction fails, the entire transaction fails.
Aggregation - A feature of the entity relationship model that allows a relationship set to participate in another relationship set.
This is indicated on an ER diagram by drawing a dashed box around the aggregation.
Two important pieces of RDBMS architecture are the kernel, which is the software, and the data dictionary, which consists of
the system- level data structures used by the kernel to manage the database.
I/O, Security, Language Processing, Process Control, Storage Management, Logging and Recovery, Distribution
Control, Transaction Control, Memory Management, Lock Management.
· Data isolation.
· Data integrity.
· Security Problems.
This language is to specify the internal schema. This language may Specify the mapping between two schemas.
Concurrency control is the process managing simultaneous operations against a database so that database integrity is no
compromised. There are two approaches to concurrency control.
The pessimistic approach involves locking and the optimistic approach involves versioning.
41. Describe the difference between homogeneous and heterogeneous distributed database?
A homogenous database is one that uses the same DBMS at each node. A heterogeneous database is one that may have a
different DBMS at each node.
A distributed database is a single logical database that is spread across more than one node or locations that are all connected
via some communication link.
The application code is stored on the application server and the database is stored on the database server. A two-tier
architecture includes a client and one server layer. The database is stored on the database server.
Data definition language commands are used to create, alter, and drop tables. Data manipulation commands are used to
insert, modify, update, and query data in the database. Data control language commands help the DBA to control the
database.
Relations in a database have a unique name and no multivalued attributes exist. Each row is unique and each attribute within a
relation has a unique name. The sequence of both columns and rows is irrelevant.
An Internet database is accessible by everyone who has access to a Web site. An intranet database limits access to only people
within a given organization.
Deadlock is a unique situation in a multi user system that causes two or more users to wait indefinitely for a locked resource.
A catalog is a table that contains the information such as structure of each file, the type and storage format of each data item
and various constraints on the data .The information stored in the catalog is called Metadata.
Data warehousing and OLAP (online analytical processing) systems are the techniques used in many companies to extract and
analyze useful information from very large databases for decision making .
Logical level: The next higher level of abstraction, describes what data are stored in database and what relationship among
those data.
View level: The highest level of abstraction describes only part of entire database.
Data independence means that the application is independent of the storage structure and access strategy of data.
One-to-one
One-to-many
Many-to-many
ORDER BY clause helps to sort the data in either ascending order to descending
DBCC stands for database consistency checker. We use these commands to check the consistency of the databases, i.e.,
maintenance, validation task and status checks.
Collation refers to a set of rules that determine how data is sorted and compared.
Delete command removes the rows from a table based on the condition that we provide with a WHERE clause. Truncate will
actually remove all the rows from a table and there will be no data in the table after we run the truncate command.
This is a primary file organization technique that provides very fast access to records on certain search conditions.
A transaction is a logical unit of database processing that includes one or more database access operations.
Analysis phase
Redo phase
Undo phase
61. What are the primitive operations common to all record management System?
62. Explain the differences between structured data and unstructured data.
Structured data are facts concerning objects and events. The most important structured data are numeric, character, and
dates.
Structured data are stored in tabular form. Unstructured data are multimedia data such as documents, photographs, maps,
images, sound, and video clips. Unstructured data are most commonly found on Web servers and Web-enabled databases.
63. What are the major functions of the database administrator?
Managing database structure, controlling concurrent processing, managing processing rights and responsibilities, developing
database security, providing for database recovery, managing the DBMS and maintaining the data repository.
A dependency graph is a diagram that is used to portray the connections between database elements.
65. Explain the difference between an exclusive lock and a shared lock?
An exclusive lock prohibits other users from reading the locked resource; a shared lock allows other users to read the locked
resource, but they cannot update it.
66. Explain the "paradigm mismatch" between SQL and application programming languages.
SQL statements return a set of rows, while an application program works on one row at a time. To resolve this mismatch the
results of SQL statements are processed as pseudofiles, using a cursor or pointer to specify which row is being processed.
The advantages of stored procedures are (1) greater security, (2) decreased network traffic, (3) the fact that SQL can be
optimized and (4) code sharing which leads to less work, standardized processing, and specialization among developers.
Entities have attributes. Attributes are properties that describe the entity's characteristics. Entity instances have identifiers.
Identifiers are attributes that name, or identify, entity instances.
70. What is Enterprise Resource Planning (ERP), and what kind of a database is used in an ERP application?
Enterprise Resource Planning (ERP) is an information system used in manufacturing companies and includes sales, inventory,
production planning, purchasing and other business functions. An ERP system typically uses a multiuser database.
Embedded SQL is the process of including hard coded SQL statements. These statements do not change unless the source code
is modified. Dynamic SQL is the process of generating SQL on the fly.The statements generated do not have to be the same
each time.
A join allows tables to be linked to other tables when a relationship between the tables exists. The relationships are established
by using a common column in the tables and often uses the primary/foreign key relationship.
A subquery is a query that is composed of two queries. The first query (inner query) is within the WHERE clause of the other
query (outer query).
The hierarchical model is a top-down structure where each parent may have many children but each child can have only one
parent. This model supports one-to-one and one-to-many relationships.
The network model can be much more flexible than the hierarchical model since each parent can have multiple children but
each child can also have multiple parents. This model supports one-to-one, one-to-many, and many-to-many relationships.
A dynamic view may be created every time that a specific view is requested by a user. A materialized view is created and or
updated infrequently and it must be synchronized with its associated base table(s).
76. Explain what needs to happen to convert a relation to third normal form.
First you must verify that a relation is in both first normal form and second normal form. If the relation is not, you must
convert into second normal form. After a relation is in second normal form, you must remove all transitive dependencies.
A unique primary index is unique and is used to find and store a row. A nonunique primary index is not unique and is used to
find a row but also where to store a row (based on its unique primary index). A unique secondary index is unique for each row
and used to find table rows. A nonunique secondary index is not unique and used to find table rows.
Minimum cardinality is the minimum number of instances of an entity that can be associated with each instance of another
entity. Maximum cardinality is the maximum number of instances of an entity that can be associated with each instance of
another entity.
79. What is deadlock? How can it be avoided? How can it be resolved once it occurs?
Deadlock occurs when two transactions are each waiting on a resource that the other transaction holds. Deadlock can be
prevented by requiring transactions to acquire all locks at the same time; once it occurs, the only way to cure it is to abort one
of the transactions and back out of partially completed work.
An ACID transaction is one that is atomic, consistent, isolated, and durable. Durable means that database changes are
permanent. Consistency can mean either statement level or transaction level consistency. With transaction level consistency, a
transaction may not see its own changes.Atomic means it is performed as a unit.
Indexes can be created to enforce uniqueness, to facilitate sorting, and to enable fast retrieval by column values. A good
candidate for an index is a column that is frequently used with equal conditions in WHERE clauses.
SQL is a language that provides an interface to RDBMS, developed by IBM. SQL SERVER is a RDBMS just like Oracle, DB2.
It is the process of defining a set of subclasses of an entity type where each subclass contain all the attributes and
relationships of the parent entity and may have additional attributes and relationships which are specific to itself.
It is the process of finding common attributes and relations of a number of entities and defining a common super class for
them.
Proactive Update: The updates that are applied to database before it becomes effective in real world.
Retroactive Update: The updates that are applied to database after it becomes effective in real world.
Simultaneous Update: The updates that are applied to database at the same time when it becomes effective in real world.
Redundant array of inexpensive (or independent) disks. The main goal of raid technology is to even out the widely different
rates of performance improvement of disks against those in memory and microprocessor. Raid technology employs the
technique of data striping to achieve higher transfer rates.
A schedule S is serial if, for every transaction T participating in the schedule, all the operations of T is executed consecutively
in the schedule, otherwise, the schedule is called non-serial schedule.
A schedule is said to be view serializable if it is view equivalent with some serial schedule.
CN’’
1. Define Network?
A network is a set of devices connected by physical media links. A network is recursively is a connection of two or
more nodes by a physical link or two or more networks connected by one or more nodes.
2. What is Protocol?
A protocol is a set of rules that govern all aspects of information communication.
3. What is a Link?
At the lowest level, a network can consist of two or more computers directly connected by some physical medium such
as coaxial cable or optical fiber. Such a physical medium is called as Link.
4. What is a node?
A network can consist of two or more computers directly connected by some physical medium such as coaxial cable or
optical fiber. Such a physical medium is called as Links and the computer it connects is called as Nodes.
58. What is the minimum and maximum length of the header in the TCP segment and IP datagram?
The header should have a minimum length of 20 bytes and can have a maximum length of 60 bytes.
59. What are major types of networks and explain?
Server-based network: provide centralized control of network resources and rely on server computers to provide
security and network administration
Peer-to-peer network: computers can act as both servers sharing resources and as clients using the resources.
STAR topology: In this all computers are connected using a central hub.
Advantages: Can be inexpensive, easy to install and reconfigure and easy to trouble shoot physical problems.
a. 256
b. 255
c. 254
d. 258
Answer: c. 254
The number of addresses usable for addressing specific hosts in each network is always 2 power N - 2 (where N is the number
of rest field bits, and the subtraction of 2 adjusts for the use of the all-bits-zero host portion for network address and the all-
bits-one host portion as a broadcast address. Thus, for a Class C address with 8 bits available in the host field, the number of
hosts is 254
a. Message
b. Datagram
c. User Datagram
d. Signals
Answer:a.Message
The data unit created at the application layer is called a message, at the transport layer the data unit created is called either a
segment or an user datagram, at the network layer the data unit created is called the datagram, at the data link layer the
datagram is encapsulated in to a frame and finally transmitted as signals along the transmission media
b. SNMP
Answer:c. UDP
DNS uses UDP for communication between servers. It is a better choice than TCP because of the improved speed a
connectionless protocol offers. Of course, transmission reliability suffers with UDP
4. Which of the following is used to direct a packet inside an internal networks?
a. Routers
b. Modem
c. Gateway
Answer: a.Routers
Routers are machines that direct a packet through the maze of networks that stand between its source and destination.
Normally a router is used for internal networks while a gateway acts a door for the packet to reach the ‘outside’ of the internal
network
1) What is polymorphism?
Polymorphism is a concept by which we can perform a single action in different ways. Polymorphism is derived from
two Greek words: poly and morphs. The word "poly" means many and "morphs" means forms. So polymorphism
means many forms.
A linked list consists of two parts. Information part and the link part. In the single linked list, first node of the list is
marked by a unique pointer named as start and this pointer points to the first element of the list, and the link part of
each node consists of a pointer pointing to the next node, but the last node of the list has null pointer identifying the
last node. The linked list can be traversed easily with the help of Start pointer.
Normalization is also known as the process of organizing data in a DBMS efficiently without any loss of data.
First is eliminating redundant data and ensuring data dependencies make sense. It reduces the amount of space that
the database consumes and ensure that data is logically stored.
Join:
This clause is used in DBMS to combine rows from two or more tables, based on a related column between them.
Keys:
Keys are a crucial part of the relational database model. They are used to identify and establish relationships between
tables. They are also used to uniquely determine each record or row of data in a table.
Key:
4) What is inheritance?
Types of Inheritance:
o Single inheritance
o Multiple Inheritance
o Multi-level Inheritance
o Multi-path Inheritance
o Hierarchical Inheritance
o Hybrid Inheritance
To execute a block of statement several times in a program depending upon the conditional statement loops are used.
The basic structure of a loop is given above in the diagram. For each successful execution of the loop, the conditional
statement should be checked. If the conditional statement is true, then the loop will be executed. If the conditional
statement is false, then the loop will be terminated.
o The instance of the class can be created by creating its object, whereas interfaces cannot be instantiated as
all the methods in the interface are abstract and do not perform any action, There is no need for instantiating
an interface.
o A class is declared using class keyword whereas an interface is declared using interface keyword.
o The members of the class can have access specifier such as public, protected, and private but members of
the interface cannot have the access specifier, all the members of the interface is declared as public because
the interface is used to derive another class. There will be no use of access specifies inside the members of
an interface.
o The methods inside the class are defined to perform some actions on the fields declared in the class whereas
interface lacks in declaring in fields, the methods in an interface are purely abstract.
o A class can implement any number of the interface but can only extend one superclass, whereas interface
can extend any number of interfaces but cannot implement any interface.
o A class can have a constructor defined inside the class to declare the fields inside the class, whereas
interface doesn't have any constructor defined because there are no fields to be initialized.
SDLC is a process followed for developing and enhancing software project. It consists of a detailed plan for developing,
maintaining a specific software. The life cycle defines a methodology process for improving the quality of software and
the overall development process.
In "The Waterfall" model, the whole process of software development is divided into separate phases. In this Waterfall
model, typically, the outcome of one phase acts as the input for the next phase sequentially.
The four basic principles of Object-Oriented Programming System are listed below:
1. Abstraction
2. Inheritance
3. Encapsulation
4. Polymorphism.
The conditional statements can alternatively be called a conditional expression also. Conditional statements are the set
of rules which were executed if a particular condition is true. It is often referred to an if-then statement because if the
condition is true, then the statement is executed.
A Database Management System is a software system is used for creating and managing databases. DBMS make it
possible for the end user to create and maintain databases. DBMS provides an interface between the end
user/application and the databases.
The object-relational database (ORD) is a database management system (DBMS) that are composed of both an
object-oriented database (OODBMS) and a relational database (RDBMS). ORD supports the essential components of
an object-oriented database model in its schemas and the query language used, such as inheritance, classes, and
objects.
IC refers to integrated circuits sets of electronic circuits on single flat piece semiconductor material, and usually,
silicon is used. The integration of a large number of tiny transistors into a small chip results in circuits that are smaller
in size and faster than those discrete electronic components. The importance of integrated circuits than the separate
electronic components is integrated circuits are smaller in size, faster, low costs than discrete electronic components.
17) Write a program to check whether the input number is a perfect number or not.
1. #include <stdio.h>
2.
3. int main()Improved data sharing.
4. {
5. int number, remainder, sum = 0, i;
6.
7. printf("Enter a Number\n");
8. scanf("%d", &number);
9. for (i = 1; i < number ; i=i+1)
10. {
11. remainder = number % i;
12. if (remainder == 0)
13. {
14. sum += i;
15.
16. }
17. }
18. if (sum == number)
19. {
20. printf("Number is perfect number");
21. }
22. else
23. {
24. printf("Number is not a perfect number");
25. }
26. return 0;
27. }
A Data Source Name as the name suggests it is the logical name for Open Database Connectivity to refer to other
information that is required to access data. For a connection to an ODBC data source Microsoft SQL Server database.
19) What is the difference between a Clustered-index and a non-clustered-index?
Faster to read than non clustered because the data is physically stored in index order
C Language
1. C is a type of the computer programming language. C was initially developed by Dennis Ritchie in AT&T Bell
Labs between 1969 and 1973. It has a free-format program source code. C is a general-purpose
programming language.
2. C is generally used for desktop computers
3. C can use the resources of a desktop PC like memory, OS, etc.
4. Compilers for C (ANSI C) typically generate OS dependent executables.
Embedded C
1. Embedded C is the set of language extensions for the C Programming language. It was released by the C
Standards committee. Through the Embedded C extensions, the C Standards committee hoped to address
the commonality issues that exist between C extensions for different embedded systems.
2. Embedded C is for micro-controller based applications.
3. Embedded C is used with the limited resources, such as RAM, ROM, I/Os on an embedded processor.
4. Embedded C requires compilers to create files to be downloaded to the micro-controllers/microprocessors
where it needs to run.
The pointer is a particular variable which holds the address of another variable of the same type. Pointers can be of
any data type and structure are allowed in C programming language. Pointer variable stores the address of another
variable of the same data type as the value of the pointer variable.
The Socket is the Combination of Ip address, and Port Number and the session is a Logical Connectivity between the
source and destination.
23) What is a null pointer?
The null pointer is the pointer with no reference to any location of the memory.
A null pointer contains zero as its value which means pointer is empty and not pointing to anywhere in the memory.
Null pointers can be used further in the program to initialize the address of the memory location with the same data
type of the pointer.
Note: Pointers can only point to the variable having the same datatype. If the data type of pointer and datatype of pointing
variable is different, then the pointer will not work.
A real-time operating system is an operating system which acts as an interface between hardware and user. This
system guarantees a specific capability within a specified time. For example, an operating system is designed to
ensure that a specific object was available for a robot on an assembly line.
26) Write a c program to swap two numbers without using a temporary variable.
1. void swap(int &i, int &j)
2. {
3. i=i+j;
4. j=i-j;
5. i=i-j;
6. }
The Function calloc() allocates a memory area, and the length will be the product of its parameters(it has two
parameters). It fills the memory with ZERO's and returns a pointer to the first byte of the memory. If it fails to locate
enough space, Then it returns a NULL pointer.
The function malloc() allocates a memory area, and length will be the value entered as a parameter. (it has one
parameter). It does not initialize memory area free() used to free the allocated memory(allocated through calloc and
malloc), in other words, this used release the allocated memory new also used to allocate memory on the heap and
initialize the memory using the constructor delete also used release memory allocated by new operator
28) Write output of the program?
1. int i=10;
2. printf("%d%d%d",i,++i,i++);
3. Answer = 10 12 12
29) What is a virtual function and what is the pure virtual function?
Virtual function:- In order to achieve polymorphism, function in base class is declared as virtual, By declare virtual
we make the base class pointer to execute the function of any derived class depends on the content of pointer (any
derived class address).
Pure Virtual Function:- This is a function used in base class, and its definition has to be provided in a derived class,
In other pure virtual function has no definition in the base is defined as:
That means this function not going to do anything, In case of the pure virtual function derived function has to
implement the pure virtual function or redeclare it as the pure virtual function
WPF/WCF application, need in .NET 3.0 Framework. This application will cover the following concepts:
31) Difference between the EXE and the DLL file extension?
The term EXE is a short-term of the word executable as it identifies the file as a program. Whereas, DLL stands for
Dynamic Link Library, which commonly contains functions and procedures that can be used by other programs.
32) Scenarios in which the web application should be used and scenarios in which
desktop application should be used?
Safe for computationally expensive software that needs to communicate directly with the OS.
The desktop application is often offline and does not need an Internet connection to function compared to a web
application.
An array is a group of elements used to store a group of related data of the same data type.
A table is a set of related data in a structured format in the database. A table is consists of rows and columns.
An array is the group of similar elements having the same data type, whereas the pointer is a variable pointing to
some data type in the memory. Arrays can only contain the elements of similar data type whereas pointer variable is
used to point to any data type variable.
Abstraction and encapsulation are complementary because in object-oriented programming classes can only be
abstracted if it is encapsulated. The abstraction focuses on the observable behavior of an object, whereas
encapsulation focuses on the implementation that gives rise to this behavior.
38) How is modularity present in C++?
Modularity is the concept explained in oops concept, and it was introduced with class and objects in c++. Functions,
classes, structures implements modularity in C++.
39) Define the structural difference between the b-tree index and bitmap?
Btree
This tree structure is a height-balanced m-way search tree. A B-tree of the order m can be defined as an m-way
search tree.
Bitmap
It consists merely of bits for every single distinct value. It uses a string of bits to locate rows in a table quickly. Used
to index low cardinality columns.
The platform independence refers to the ability of programming language or a platform that you implement on one
machine and use them on another machine without or minimal changes. There are two types of platform
independence, source platform independence, and binary platform independence. For example, Java is a binary
platform independent language whereas c and c++ are source platform independence languages because java uses
java virtual machine to run their programs but c and c++ use compilers to convert the source code to executable
machine language.
Char and Varchar both are the datatypes in DBMS. Char and varchar both datatypes are used to store characters up to
8000. The only point of difference between the Char and Varchar is Char fixed length string datatype whereas Varchar,
as the name suggests, is a variable length character storing data type.
For example, char(7) will take 7 bytes of memory to store the string, and it also includes space. Whereas varchar will
take variable space, which means that it will only take that much of space as the actual data entered as the data of
varchar data type.
o Low-level Language- Language which is understandable by machine is often known as machine language
(binary language). It is challenging to read and doing code in this language by humans directly.
o Assembly level language- Some mnemonics are used which reduce the complexity of the program.
o Middle-level Language- This language is not so tricky as the assembly language, but it still requires the
knowledge of computer hardware which makes it little difficult to program. For Example C and C++
programming languages.
o High-level language- Its right to say, this level of the programming language is the highest level of the
programming language in the technology. These types of programming languages do not require the
knowledge of the hardware. This level of the programming language is elementary to learn by the humans.
For Example Java, PHP, Perl, Python, etc.
43) What is the word used for the virtual machine in JAVA? How is it implemented?
The word "Java Virtual Machine known as JVM in short" is used for the virtual machine in Java. This word is
implemented from the java runtime environment (JRE).
44) List the areas in which data structures are applied extensively?
The list of areas where data structures are applied extensively are listed below:
o Compiler Design
o Operating System
o Database management System
o Numerical analysis
o Artificial Intelligence
o Simulation
o Statistical analysis package
A structure and a class differ a lot as a structure has limited functionality and features as compared to a class. A class
can be defined as the collection of related variables and functions encapsulated in a single structure whereas a
structure can be referred to as an user-defined datatype for processing its operations. A keyword "Struct" is used for
declaration of Struct Where a keyword "class" is used for the declaration of a class in the programming language.
Default access specifier of the class is private whereas default access specifier of the struct is public. The purpose of
the class is data abstraction and further inheritance whereas the use of the struct is generally, Grouping of data.
General usage of the struct is a small amount of data whereas general usage of the class is to store a large amount of
data.
46) What is the difference between a white box, black box, and gray box testing?
White Box Testing Black Box Testing Gray Box Testing
Internal programming fully known. Internal programming is not known. Internal programming is
partially known.
Tester knows the internal working of the The knowledge of the internal working Internal working of the
application. of the application is not required. application is partially known.
White box testing is also known as glass, Black box testing is also known as a Gray box testing is also known
open box, clear box, structural testing, or closed box, data-driven, and as translucent testing.
code-based testing. functional testing.
Performed by tester and developers. Performed by the end user and also Performed by the end user and
by tester and developers. also by tester and developers.
The tester can design test data. Testing is based on external By high-level database
expectation. diagrams and data flow
diagrams.
Most exhaustive and time-consuming. Least time consuming and exhaustive. Partially time-consuming and
exhaustive.
Data domain and internal boundaries can be Performed by the trial, and error Data domains and the internal
better tested. method. boundaries can be tested if
known.
Not suited for algorithm testing. Not suited for algorithm testing. Suited for algorithm testing.
47) Describe three levels of data abstraction? Which layer is at the user end?
1. Physical level: This is the lowest level of database abstraction describes how the data are stored.
2. Logical level: This level is the next higher level than the physical level of database abstraction, which
represents the data stored in the database and what relationship among those data.
3. View level: This is the highest level of database abstraction describes only part of the entire database.
49) Write the program in C language to swap two numbers without using a third
variable.
1. #include<Stdio.h>
2. #include<conio.h>
3. void main()
4. {
5. int i,j;
6. printf("Enter the value of i: \n");
7. scanf("%d",&i);
8. printf("Enter the value of j: \n");
9. scanf("%d",&j);
10. printf("Value of i before swap:%d \n",i);
11. printf("Value of j before swap:%d \n",j);
12. i=i+j;
13. j=i-j;
14. i=i-j;
15. printf("Value of i after swap:%d \n",i);
16. printf("Value of j after swap:%d \n",j);
17.
18. }
The older version of the IP address. The newer version of the IP address.
generates 4.29 x 109 unique network addresses produces 3.4 x 1038 addresses
C and C++ both use the same syntax. C++ is the extension of the C language. C and C++ both have same compilers.
C++ language consists of classes and objects whereas there are no classes and objects available in the C language.
C++ is an OOP based programming whereas C is not OOPS based programming language.
The two types of modulation techniques are an analog and digital modulation. Further analog modulation is subdivided
into amplitude, frequency and phase modulation.
The pre-processor is just a text substitution tool, and they instruct the compiler to do required pre-processing before
actual compilation.
55) Write a program in c language to check whether the input number is a prime
number or not.
1. #include<conio.h>
2. #include<stdio.h>
3.
4. int main()
5. {
6. int num,i;
7. int flag=0;
8. printf("Enter the number:");
9. printf("\n");
10. scanf("%d",&num);
11. for(i=2;i<num;i++)
12. {
13. if(num%i==0)
14. {
15. flag++;
16. }
17. }
18. if(flag>0)
19. {
20. printf("number is not a prime number\n");
21. }
22. else
23. {
24. printf("Entered number is an prime number\n");
25. }
26. return;
27. }