- What is a class?
- What is an object?
- What is the difference between an object and a class?
- What is the difference between class and structure?
- What is public, protected, private?
- What are virtual functions?
- What is friend function?
- What is a scope resolution operator?
- What do you mean by inheritance?
- What is abstraction?
- What is polymorphism? Explain with an example.
- What is encapsulation?
- What do you mean by binding of data and functions?
- What is function overloading and operator overloading?
- What is virtual class and friend class?
- What do you mean by inline function?
- What do you mean by public, private, protected and friendly?
- When is an object created and what is its lifetime?
- What do you mean by multiple inheritance and multilevel inheritance? Differentiate between them.
- Difference between realloc() and free?
- What is a template?
- What are the main differences between procedure oriented languages and object oriented languages?
- What is R T T I ?
- What are generic functions and generic classes?
- What is namespace?
- What is the difference between pass by reference and pass by value?
- Why do we use virtual functions?
- What do you mean by pure virtual functions?
- What are virtual classes?
- Does c++ support multilevel and multiple inheritance?
- What are the advantages of inheritance?
- When is a memory allocated to a class?
- What is the difference between declaration and definition?
- What is virtual constructors/destructors?
- In c++ there is only virtual destructors, no constructors. Why?
- What is late bound function call and early bound function call? Differentiate.
- How is exception handling carried out in c++?
- When will a constructor executed?
- What is Dynamic Polymorphism?
- Write a macro for swapping integers.
Frequently asked Questions for Interview on C++
Frequently asked questions in C for Placement interview
- What does static variable mean?
- What is a pointer?
- What is a structure?
- What are the differences between structures and arrays?
- In header files whether functions are declared or defined?
- What are the differences between malloc() and calloc()?
- What are macros? what are its advantages and disadvantages?
- Difference between pass by reference and pass by value?
- What is static identifier?
- Where are the auto variables stored?
- Where does global, static, local, register variables, free memory and C Program instructions get stored?
- Difference between arrays and linked list?
- What are enumerations?
- Describe about storage allocation and scope of global, extern, static, local and register variables?
- What are register variables? What are the advantage of using register variables?
- What is the use of typedef?
- Can we specify variable field width in a scanf() format string? If possible how?
- Out of fgets() and gets() which function is safe to use and why?
- Difference between strdup and strcpy?
- What is recursion?
- Differentiate between a for loop and a while loop? What are it uses?
- What are the different storage classes in C?
- Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?
- What is difference between Structure and Unions?
- What the advantages of using Unions?
- What are the advantages of using pointers in a program?
- What is the difference between Strings and Arrays?
- In a header file whether functions are declared or defined?
- What is a far pointer? where we use it?
- How will you declare an array of three function pointers where each function receives two ints and returns a float?
- what is a NULL Pointer? Whether it is same as an uninitialized pointer?
- What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?
- What does the error 'Null Pointer Assignment' mean and what causes this error?
- What is near, far and huge pointers? How many bytes are occupied by them?
- How would you obtain segment and offset addresses from a far address of a memory location?
- Are the expressions arr and &arr same for an array of integers?
- Does mentioning the array name gives the base address in all the contexts?
- Explain one method to process an entire string as one unit?
- What is the similarity between a Structure, Union and enumeration?
- Can a Structure contain a Pointer to itself?
- How can we check whether the contents of two structure variables are same or not?
- How are Structure passing and returning implemented by the complier?
- How can we read/write Structures from/to data files?
- What is the difference between an enumeration and a set of pre-processor # defines?
- what do the 'c' and 'v' in argc and argv stand for?
- Are the variables argc and argv are local to main?
- What is the maximum combined length of command line arguments including the space between adjacent arguments?
- If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?
- Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?
- What are bit fields? What is the use of bit fields in a Structure declaration?
- To which numbering system can the binary number 1101100100111100 be easily converted to?
- Which bit wise operator is suitable for checking whether a particular bit is on or off?
- Which bit wise operator is suitable for turning off a particular bit in a number?
- Which bit wise operator is suitable for putting on a particular bit in a number?
- Which bit wise operator is suitable for checking whether a particular bit is on or off?
- which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?
- Write a program to compare two strings without using the strcmp() function.
- Write a program to concatenate two strings.
- Write a program to interchange 2 variables without using the third one.
- Write programs for String Reversal & Palindrome check
- Write a program to find the Factorial of a number
- Write a program to generate the Fibinocci Series
- Write a program which employs Recursion
- Write a program which uses Command Line Arguments
- Write a program which uses functions like strcmp(), strcpy()? etc
- What are the advantages of using typedef in a program?
- How would you dynamically allocate a one-dimensional and two-dimensional array of integers?
- How can you increase the size of a dynamically allocated array?
- How can you increase the size of a statically allocated array?
- When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
- Which function should be used to free the memory allocated by calloc()?
- How much maximum can you allocate in a single call to malloc()?
- Can you dynamically allocate arrays in expanded memory?
- What is object file? How can you access object file?
- Which header file should you include if you are to develop a function which can accept variable number of arguments?
- Can you write a function similar to printf()?
- How can a called function determine the number of arguments that have been passed to it?
- Can there be at least some solution to determine the number of arguments passed to a variable argument list function?
- How do you declare the following:
- An array of three pointers to chars
- An array of three char pointers
- A pointer to array of three chars
- A pointer to function which receives an int pointer and returns a float pointer
- A pointer to a function which receives nothing and returns nothing
- What do the functions atoi(), itoa() and gcvt() do?
- Does there exist any other function which can be used to convert an integer or a float to a string?
- How would you use qsort() function to sort an array of structures?
- How would you use qsort() function to sort the name stored in an array of pointers to string?
- How would you use bsearch() function to search a name stored in array of pointers to string?
- How would you use the functions sin(), pow(), sqrt()?
- How would you use the functions memcpy(), memset(), memmove()?
- How would you use the functions fseek(), freed(), fwrite() and ftell()?
- How would you obtain the current time and difference between two times?
- How would you use the functions randomize() and random()?
- How would you implement a substr() function that extracts a sub string from a given string?
- What is the difference between the functions rand(), random(), srand() and randomize()?
- What is the difference between the functions memmove() and memcpy()?
- How do you print a string on the printer?
- Can you use the function fprintf() to display the output on the screen?
Technical Aptitude Question Paper for Practice :: #Campus Placement
- #include<stdio.h>
int main()
{
char ch;
while
(x=0;x<=255;x++)
printf("ASCII
value of %d character %c\n", x, x);
return 0;
}
A. The code
generates an infinite loop B. The
code prints all ASCII values and its characters
C. Error: x
undeclared identifier D. Error: while statement missing
- #include<stdio.h>
int main()
{
int i,
a[] = {2, 4, 6, 8,
10};
change(a, 5);
for(i=0; i<=4;
i++)
printf("%d,
", a[i]);
return 0;
}
change(int *b, int
n)
{
int i;
for(i=0; i<n;
i++)
*(b+1) =
*(b+i)+5;
}
A. 7, 9, 11, 13,
15 B. 2, 15, 6, 8, 10 C. 2 4 6 8 10 D. 3, 1, -1, -3, -5
3)
#include<stdio.h>
int fun(int, int);
typedef int (*pf)
(int, int);
int proc(pf,
int,int);
int main()
{
printf("%d\n",
proc(fun, 6, 6));
return 0;
}
int fun(int a, int
b)
{
return
(++a!=b++);
}
int proc(pf p, int
a, int b)
{
return ((*p)(a,
b));
}
A. 6 B. 1 C. 0 D.
-1
4) main()
{
fork();
fork();
fork();
printf("Hello
World!");
}
A. compiler
error B. print hello world 4 time
C. print hello
world 6 time D. print hello world 8 time
5) C program code
–
int zap(int n)
{
if(n<=1)then
zap=1;
else
zap=zap(n-3)+zap(n-1);
}
then the call
zap(6) gives the values of zap
A. 8 B. 9
C. 6 D. 12 E. 15
6) Virtual memory
size depends on
A. address
lines B. data bus C. disc space D. A & C E. None
7) What will be
the output of the following program :
struct {
int i, val[25];
}var={1,2,3,4,5,6,7,8,9},*vptr=&var;
void main()
{
printf("%d
%d %d\n",var.i,vptr->i,(*vptr).i);
printf("%d
%d %d %d %d %d",var.val[4],*(var.val+4),vptr->val[4],*(vptr->val+4),
(*vptr).val[4],*((*vptr).val+4));
}
- Compile-Time Error B. 1 1 1 C. 1 1 1 D. None of these
666666 555555
8) What will
be the output of the following program :
struct
my_struct1{
int arr[2][2];
};
typedef struct
my_struct1 record;
struct
my_struct2{
record temp;
}list[2]={1,2,3,4,5,6,7,8};
void main()
{
int i,j,k;
for (i=1; i>=0;
i--)
for (j=0; j<2;
j++)
for (k=1; k>=0;
k--)
printf("%d",list[i].temp.arr[j][k]);
}
- Compile-Time Error B. Run-Time Error C. 65872143 D. 56781243
9) What will be
the output of the following program :
union A{
char ch;
int i;
float f;
}tempA;
void main()
{
tempA.ch='A';
tempA.i=777;
tempA.f=12345.12345;
printf("%d",tempA.i);
}
- Compile-Time Error B. 12345 C. Erroneous output D. 777
10) What will be
the output of the following program :
struct A{
int i;
float f;
union B{
char ch;
int j;
}temp;
}temp1;
void main()
{
struct A
temp2[5];
printf("%d
%d",sizeof temp1,sizeof(temp2));
}
A. 12 60 B. 60 12
C. compile time error D. none
11) What will be
the output of the following program?
void main()
{
static struct
my_struct{
unsigned a:1;
unsigned b:2;
unsigned c:3;
unsigned d:4;
unsigned :6; //
Fill out first word
}v={1,2,7,12};
printf("%d
%d %d %d",v.a,v.b,v.c,v.d);
printf("%d
",sizeof v);
}
- 1 2 7 12 4 B. 12 7 2 1 2 C. compile time error D. none
12) What will be
the output of the following program :
void main()
{
printf();
}
- Run-Time Error B. Compile-Time Error C. No Output D. None of these
13)What will be
the output of the following program :
void main()
{
printf("%d",printf("Hi!")*printf("Bye"));
}
- ByeHi!6 B. Hi!Bye9 C. Hi!Bye D. None of these
14) What will
be the output of the following program :
#define
Compute(x,y,z) (x+y-z)
void main()
{
int x=2,y=3,z=4;
printf("%d",Compute(y,z,(-x+y))
* Compute(z,x,(-y+z)));
}
- 20 B. 30 C. 100 D. None
15)What will be
the output of the following program :
void main()
{
int i;
float a[5];
for (i=0; i<5;
i++)
a[i] = (printf,
("%d",i/10.0));
for (i=0; i<5;
i++)
printf("%.1f
",a[i]);
}
- Compile-Time Error B. 0.0 0.0 0.0 0.0 0.0 C. 0.0 0.1 0.2 0.3 0.4 D. 1.0 1.0 1.0 1.0 1.0
16) What will be
the output of the following program :
int * func()
{
int temp=50;
return&temp;
}
void main()
{
int *val;
val = func();
printf("%d",*val);
}
- Compile-Time Error B. 50 C. Garbage Value D. None of these
17) What will be
the output of the following program :
void main()
{
long double val;
printf("%d
bytes",sizeof(val));
}
- Compile-Time Error B. 4 bytes C. 8 bytes D. 10 bytes
18) What will be
the output of the following program :
#define Loop(i)
for (j=0; j<i; j++){ \
sum += i+j; \
}
void main()
{
int i,j,sum=0;
for (i=0; i<=3;
i++)
Loop(i)
printf("%d",sum);
}
- Run-Time Error B. Compile-Time Error C. 18 D.0
19) What will be
the output of the following program :
void main()
{
int i;
for (i=5; ++i;
i-=3)
printf("%d
",i);
}
- 6 4 2 B. Compile-Time Error C. 6 3 1 D. Infinite Loop
20) What will be
the output of the following program :
void main()
{
static int j;
for (j<5; j<5;
j+=j<5)
printf("%d",j++);
}
- 024 B. Compile-Time Error C. 01234 D. No Output
21) What will be
the output of the following program :
void main()
{
for
(;printf(""););
}
- Compile-Time error B. NO OUTPUT C. Executes INFINITELY D. None of these
22) What will be
the output of the following program :
void main()
{
static int
choice;
switch(--choice,choice-1,choice-1,choice+=2)
{
case 1:
printf("Choice1");
break;
case 2:
printf("Choice2");
break;
default:
printf("Default");
}
}
- Choice1 B. Choice2 C. Default D. Compile error
23) What will be
the output of the following program?
int funct(char
ch)
{
ch=ch+1;
return ch;
}
void main()
{
int a=127;
printf("%d
%d",a,funct(a));
}
- Compile-Time Error B. 127 128 C. 127 -128 D. None of these
24)What will be
the output of the following program :
int funct1(int a)
{
if (a)
return
funct1(a--)+a;
else
return 0;
}
void main()
{
int a=3;
printf("%d",funct1(a));
}
- 3 B. 6 C. 0 D. stack overflow
25) What will be
the output of the following program :
void main()
{
int (*a)[5];
printf("%d
%d",sizeof(*a),sizeof(a));
}
- Compile-Time Error B. 2 10 C. 4 20 D. 20 4
26) What will be
the output of the following program :
void main()
{
int val=77;
const int const
*ptr=&val;
printf("%d",*ptr);
}
- Compile-Time Error B. Run-Time Error C. 77 D. None of these
27)What will be
the output of the following program :
void main()
{
char
str[]="yagyesh kumar mishra";
printf("%d",++(sizeof(str)));
}
- 14 B. Compile-Time Error C. 15 D. run-time error
28) What will be
the output of the following program :
void main()
{
int a=1,b=2,c=3;
c=(--a,b++)-c;
printf("%d
%d %d",a,b,c);
}
- 0 3 -3 B. Compile-Time Error C. 0 3 -1 D. 0 3 0
29) What will be
the output of the following program :
#define swap(a,b)
temp=a; a=b; b=temp;
void main()
{
static int
a=5,b=6,temp;
if (a > b)
swap(a,b);
printf("a=%d
b=%d",a,b);
}
- a=5 b=6 B. a=6 b=5 C. a=6 b=0 D. None of these
30) What is the
difference between class and structure?
_____________________________________________________________________________________
31) Write a macro
"SWAP(a,b)" for swapping integers using bit wise operator
XOR.
_____________________________________________________________________________________
32)What is virtual
function?
_____________________________________________________________________________________
33) - ls command
stores contents in
A. inode
block B. process table C. directry entry D. current
directory
34) startup
programme of window : autoexec.bat :: startup program of Unix :
?
A. .profile B.
autoexeclp C. getty D. csh
35) Semaphore is
used for _____________________of multiple process
36) FTP transfer
file with user authentication. (TRUE/FALSE)
37) In signed
magnitude notation what is the minimum value that can be represented
with 8 bits
A. -128 B. -255
C. -127 D. 0
38)
abcD+abcd+aBCd+aBCD
then the
simplified function is –
( Capital letters
are copliments of corresponding letter for eg.A is compliment of a)
Hint
- use boolean arithmatic.
A. a B. abc
C. abcd D. a(bC+Bc) E. a(bC +BC)
39) A 12 address
lines maps to the memory of_________
A. 1k bytes B.
0.5k bytes C. 4k bytes D. None
40). What does DLL
stands for ?
A. Dynamic
Language Library B. Dynamic Link Library
C. Dynamic Load
Library D. None of the above
41) SNAPSHOT is
used for
A. Synonym B.
Table space C. System server D. Dynamic data replication
42. A Transaction
ends
A. Only when it
is Committed B. Only when it is Rolledback
C. When it is
Committed or Rolled back D. None of the above
43) A Database
Procedure is stored in the Database
A. In compiled
form B. As source code C. Both A & B D. Not stored
44) A Stored
Procedure is a
A. Sequence of
SQL or PL/SQL statements to perform specific function
B. Stored in
compiled form in the database
C. Can be called
from all client environmets
D. All of the
above
45) Which of the
following is NOT VALID in PL/SQL ?
A. Select ...
into B. Update C. Create D. Delete
46) What are the
different events in Triggers ?
A. Define,
Create B. Drop, Comment C. Insert, Update, Delete D. All of the above
47)Which layer in
the OSI model handles terminal emulation ?
A. Session B.
Application C. Presentation D. Transport E. Network
48).An internet IP
address of a node has to be unique for
A. domain of the
node B. country C. sub-network of the node D. World-wide E.
None
49) Modem stand
for
A.
Modulator/demodulators
B. Connect to multiple computers
C. Broadcast wireless signals
D. Only work with AOL
B. Connect to multiple computers
C. Broadcast wireless signals
D. Only work with AOL
50) TCP is a
connectionless protocol. TRUE/FALSE