Sei sulla pagina 1di 43

Skip to content

WP PLUGINS

WORDPRESS

WEB & DEV

LINUX

ACADEMIC

INTERNET

PROJECTS

DOWNLOADS

SEARCH

INTECHGRITY
AMALGAMATING LIFE & TECHNOLOGY

10 C programs you must know before


appearing for technical interviews
arnabJuly 25, 201229

Navigate (TOC) [hide]

#1: Swap two numbers (without using a temporary variable)

#2: Patterns (one of their favorites)

#3: Finding the nth Fibonacci number using recursion

#4: Armstrong number

#5: Concatenate two strings without using strcat()

#6: Sort elements of an array using pointers (selection sort technique)

#7: Enter and print details of n employees using structures and dynamic memory allocation

#8: Tower of Hanoi using recursion

#9: Add numbers using Command line arguments

#10: Print its own source code using File

If you havent opened Turbo C++ for more than a year and the campus
placements are not very far away then you are at the correct place. The interviewers have a thing for
C programs and theres a great chance you might be bombarded with them on the interview day. Ive
compiled 10 programs that are very common and has been asked numerous times in the interviews.
Most importantly if you practice these programs you get to revise the whole syllabus. I tried to
include as many concepts as possible keeping in mind the difficulty level matched the level of the
interview questions. If you dont get any of these questions in the interview feel free to sue this

websites admin..

Click here to check out 10 java programs for technical interview.

#1: Swap two numbers (without using a temporary


variable)
Now there are a number of ways you can do this program but there is one way you can really
impress the interviewer which uses this cool technique using bitwise operators.
?

01

//Sorting without using temporary variables

02

#include

03
04
05

#include
int main(){
int a,b;
printf("Before swapping:\n");

06
07
08

printf("Enter value of a: ");


scanf("%d",&a);
printf("Enter value of b: ");

09
scanf("%d",&b);

10

//Sorting using

11

a=a^b; //uses xor operator

12

b=a^b; //to swap the values

13

a=a^b; //of a and b

14

printf("After swapping:\n");

15

printf("Value of a: %d \nValue of b: %d",a,b);

16
17

getch();
}

18
Follow up questions:
[learn_more caption= 1. What is XOR gate?]Dont try to give them any other answers because the
answer they are looking for is XOR gate outputs 1 when there are odd number of 1s. [/learn_more]
[learn_more caption= 2. Show some other ways to do the swapping. ] You can add the two
numbers and store it in the first number and then subtract the other number from it to swap the
value. Or you can multiplyand then divide. [/learn_more]

#2: Patterns (one of their favorites)


If the interviewer asks you a pattern and you dont know how to do that you are screwed big time.
Often you might make a very simple mistake which the interviewer was actually looking for. Here
well find out how to print this pattern
?

A B C D E D C B A

A B C D C B A

A B C B A

A B A

And here is the code.


?

01

//Printing pattern

02

#include

03
04
05

#include
int main(){
int n,i,j;
printf("Enter no of lines: ");

06
07
08

scanf("%d",&n);
for(i=0;i<n;i++){
for(j=0;j<i;j++){ //for printing spaces

09

printf(" ");

10

11

for(j=0;j<n-i;j++){ //for printing the left side

12

printf("%c ",'A'+j); //the value of j is added to 'A'(ascii value=65)

13

}
for(j=n-i-2;j>=0;j--){ //for printing the right side

14

printf("%c ",'A'+j);

15
}

16
printf("\n");

17

18
19
20

getch();
}

21
Follow up questions:
[learn_more caption=1. What happens if we use %d instead of %c?] Try it out yourself.
[/learn_more]
[learn_more caption=2. Cant we use ASCII values to print this pattern?] We are indirectly using
ASCII values only. If you are still having problems you can visit my post on patterns.[/learn_more]

#3: Finding the nth Fibonacci number using recursion


There are two rules in recursion:
i. The function must have a recursive definition or in simple words can be expressed in its own form.
ii. There is a terminating value for which we know the return value of the function.
We have to make a function fibonacci in a recursive form. Well make a function fibonacci() and
make them follow the above rules:
i. fibonacci(x) = fibonacci(x-1) + fibonacci(x-2) (recursive definition)
ii. if x==0 or x==1 then return 1 (terminating step)
Now we are good to write the code:
?

01

#include

02

#include

03
04

int y;
fibonacci(int x){

05
if(x==1 || x==0) //terminating step

06

return x;

07

y=fibonacci(x-1)+fibonacci(x-2); //recursive definition

08

return y;

09

10

int main(){

11

int a,r;

12

printf("Enter the position : ");

13

scanf("%d",&a);
r=fibonacci(a);

14

printf("The number at position %d is %d",a,r);

15

getch();

16

return 0;

17

18
Follow up questions:
[learn_more caption=1. Can we use this function to print the whole Fibonacci series?] We need to
write a for loop from 1 to n and call fibonacci() for each value of i. Its a bad technique anyway so
dont use it.[/learn_more]
[learn_more caption=2. What if we pass a negative number to the fibonacci() ?] Try it yourself to
find out and rewrite the program to print 0 in that case.[/learn_more]

#4: Armstrong number


You have done great so far but dont try to do the whole tutorial all at once. Take some rest and
come back later but if u want a challenge then continue. Now what is an Armstrong number? If a
number has n digits and the sum of the nth power of its digits is the number itself then the number is
an Armstrong number. Surely you got confused. Here are some examples to help you out.

5^1=5 (so its an Armstrong number)


1^4+6^4+3^4+4^4=1634 (so its another Armstrong number)
Dont scratch your head if you cant do it yourself. The code is given below. Feel free to peek.
?

01

#include

02

#include

03

void checkArmstrong(int temp){


int sum=0,remainder,num=temp,noOfDigits=0;

04

while(temp != 0){ //counts no of digits

05

noOfDigits++;

06

temp=temp/10;

07

08

temp=num;

09

while(temp != 0){ //calculates the sum of the digits

10

remainder = temp%10; //to the power noOfDigits

11

sum = sum + pow(remainder,noOfDigits);

12

temp = temp/10;

13

}
if (num == sum) //checks if the number is an armstrong no. or not

14

printf("%d is an armstrong number.",num);

15

else

16
printf("%d is not an armstrong number.",num);

17
18
19

20
21

int main(){
int n;

22

printf("Enter a number: ");

23

scanf("%d",&n);

24
checkArmstrong(n);

25

getch();

26
27

return 0;
}

28
Follow up Questions:
[learn_more caption=1. Is 0 an Armstrong number?] No O^1=1 and not 0 thats why.[/learn_more]
[learn_more caption=2. How many 2 digit numbers are Armstrong numbers?] 0[/learn_more]
[learn_more caption=3. Why arent there any follow up question on the program?] I couldnt think of
any thats why ;-)[/learn_more]

#5: Concatenate two strings without using strcat()


We are so used to using strcat() when it comes to concatenate two strings but how can we do that
without using strcat()? To answer that you have to know what is string in C and how it is printed.
Strings in C are represented by character arrays. The end of the string is marked by a special
character known as the null character(). So to concatenate two strings you just have to add the
characters of the second character array after the first and place a null character at the end.
The code is as follows:
?

01

#include

02

#include

03
04

#include

05

void concatenate(char a[],char b[]){


char c[strlen(a)+strlen(b)]; //size of c is sum of a and b

06

int i=0,j=0;

07

while(i<strlen(a)) //adds the first string to c

08

c[i++]=a[i];

09

while(j<strlen(b)) //adds the second string to c

10

c[i++]=b[j++];

11

c[i]='\0'; //finally add the null character

12

printf("After concatenation:\n");

13

printf("Value = %s",c);

14

15

int main(){
char a[30], b[30];

16

printf("Enter the first string: ");

17

gets(a);

18

printf("Enter the second string: ");

19

gets(b);

20

concatenate(a,b);

21

getch();

22
23
24

return 0;
}

Follow up Questions:
[learn_more caption=1. What if we use scanf instead of gets?] scanf can take in only one word
whereas gets can take many words. Use scanf instead of gets to find the difference.[/learn_more]
[learn_more caption=2. What if we dont use \ at the end of the string?] It will show junk values after
the string.[/learn_more]

#6: Sort elements of an array using pointers (selection sort


technique)
Sorting is a one of the most favorite topic asked during the interviews. It is usually accompanied by
something or the other like here sorting is done indirectly using pointers. There are many sorting
techniques but usually bubble sort or selection sort is asked. Here well using the selection sort
technique to sort in ascending order. Sorting the elements of the array using pointers makes the
program a bit challenging. If there is an integer array arr[], arr is a pointer which stores the address
of the first element of arr[]. *arr can be used to refer to the value stored at that location. To access
the next element we can use *(arr+1). Using this knowledge you can start writing the program. The
code is as follows:
?

01

#include

02

#include

03
04
05

int main()
{
int arr[20], n, i, j, pos, temp;
printf("Enter number of elements (max 20): ");

06
07
08

scanf("%d", &n);
for(i=0;i<n;i++){
printf("Enter no %d: ", i+1);

09

scanf("%d",(arr+i)); //(arr+i) is the pointer to the individual elements of the array

10

11

for (i=0;i<(n-1);i++){ //selection sorting is done

12
13

pos=i;

14

for (j=i+1;j<n;j++ ){

15

pos=j;

16

17

if ( pos!=i ){ //if value of pos changes the swapping is done

if (*(arr+pos)> *(arr+j)) //checks if arr[pos] is greater than

temp= *(arr+i);

18

*(arr+i)= *(arr+pos);

19

*(arr+pos)= temp;

20
}

21

22

printf("Sorted list in ascending order:\n");

23

for(i=0;i<n;i++)

24

printf("%d ", *(arr+i));

25

getch();

26

return 0;

27

28
Follow up Questions:
[learn_more caption=1. What is the bubble sort technique?] To find about bubble sort check out the
post [/learn_more]
[learn_more caption=2. What are the other sorting techniques that are asked during the
interviews?] Its unlikely that they will ask you to write the program but logic of heap sort, merge
sort, bucket sort, quick sort and radix sort can be asked.[/learn_more]

#7: Enter and print details of n employees using structures


and dynamic memory allocation
This program is used to show the most basic use of structures. The structure is made of a character
array name[], integer age and float salary. Well make an array of the structure for the employees.
Well also use dynamic memory allocation using malloc. You can also use a linked list to the same
which is a better option. Lets check the code.
?

01

#include

02

#include

03
04
05

typedef struct{ //structure of emp


char name[30];
int age;
float salary;

06
07
08

}emp;
int main(){
int n,i;

09

emp *employee;

10

printf("Enter no of employees: ");

11

scanf("%d",&n);

12

employee=(emp*)malloc(n*sizeof(emp)); //dynamic memory allocation using


malloc()

13

for(i=0;i<n;i++){

14

printf("\n\nEnter details of employee %d\n",i+1);

15

printf("Enter name: ");

16

scanf("%s",employee[i].name);

17

printf("Enter age: ");

18
19

scanf("%d",&employee[i].age);

20

printf("Enter salary: ");

21

scanf("%f",&employee[i].salary);

22

}
printf("\nPrinting details of all the employees:\n");

23

for(i=0;i<n;i++){

24

printf("\n\nDetails of employee %d\n",i+1);

25
printf("\nName: %s",employee[i].name);

26

printf("\nAge: %d",employee[i].age);

27

printf("\nSalary: %.2f",employee[i].salary);

28

29

getch();

30

return 0;

31

32
Follow up Questions:
[learn_more caption=1. What is malloc?] malloc() is a built-in standard library function for dynamic
memory allocation. It allocates a block of size bytes from the free data area (heap). It allows a
program to allocate an exact amount of memory explicitly, as and when needed.
Syntax: void *malloc(size_t size);[/learn_more]
[learn_more caption=2. What are the other functions used in dynamic memory allocation/deallocation?] calloc, free and realloc. calloc() does the same thing as malloc but has a different
syntax. free() is used for de-allocating a memory block previously allocated by malloc() or calloc().
realloc() is used to adjust the amount of memory allocated earlier.
syntax: void *calloc(size_t nitems, size_t size);

void free(void *block);


void *realloc(void *block, size_t size);[/learn_more]
[learn_more caption=3. Why using a linked list to do this program be a better option?] Then we can
add and delete any employee details easily.[/learn_more]

#8: Tower of Hanoi using recursion


Now take a small break because you deserve it. But if you have the interview tomorrow, gulp a glass
of health drink and continue. The Tower of Hanoi is a mathematical game consisting of three rods A,
B and C and a number of disks of different sizes which can slide onto any rod. The objective of the
game is to move the entire stack from A to C using B as an auxiliary. There are few rules- Only one
disk can be moved at a time and no disk can be placed on top of a smaller disk.
Recursive solution:
1. move n1 discs from A to B. This leaves disc n alone on peg A
2. move disc n from A to C
3. move n1 discs from B to C so they sit on disc n
Heres the code:
?

01

#include

02

#include

03
04
05

void towers(int n,char frompeg,char topeg,char auxpeg){


// If only 1 disk, make the move and return
if(n==1){
printf("\nMove disk 1 from peg %c to peg %c",frompeg,topeg);

06
07
08
09

return;
}
// Move top n-1 disks from A to B, using C as auxiliary
towers(n-1,frompeg,auxpeg,topeg);

10
11

// Move remaining disks from A to C

12

printf("\nMove disk %d from peg %c to peg %c",n,frompeg,topeg);

13

// Move n-1 disks from B to C using A as auxiliary

14

towers(n-1,auxpeg,topeg,frompeg);
}

15

int main(){

16

int n;

17
printf("Enter the number of disks : ");

18

scanf("%d",&n);

19

printf("The Tower of Hanoi involves the moves :\n\n");

20

towers(n,'A','C','B');

21

getch();

22

return 0;
}

23
24

Follow up Question:
[learn_more caption=1. Can we write of Hanoi without using recursion?] Yes we can write it without
using recursion but then we have to alternate between the smallest and the next-smallest disks.
Follow these steps:
For an even number of disks:

make the legal move between pegs A and B

make the legal move between pegs A and C

make the legal move between pegs B and C

repeat until complete

For an odd number of disks:

make the legal move between pegs A and C

make the legal move between pegs A and B

make the legal move between pegs B and C

repeat until complete

In each case, a total of 2n-1 moves are made.[/learn_more]

#9: Add numbers using Command line arguments


Questions on command line arguments are very often asked in the interviews. This program will
explain most of the details about command line arguments. The main() must have two parametersint argc and char *argv[]. argc is the argument count and argv[] will store the arguments passed by
the user. argv[0] is the name of the program. In this program well have to add all the arguments
passed starting from the argv[1] to argv[argc].
The code is given below:
?

01

#include

02

#include

03

#include

04
05
06

int main(int argc,char *argv[])


{
int sum=0,i;

07
08
09

//Compare if proper number of arguments have been entered


if(argc<3)
{

10
11

printf("Insufficient number of arguments...\n");

12

getch();

13

return 0;

14

15
16
17

//Add all the numbers entered using atoi function


for(i=1;i<argc;i++)
{

18
19

sum+=atoi(argv[i]);
}

20
21

//print the sum

22

printf("Ans=%d",sum);

23

getch();

24

25
Follow up Questions:
[learn_more caption=1. How can i run this program?] First you have to compile the program. Then
you have to run the program in command prompt and also provide the command line arguments
properly to get the answer.[/learn_more]
[learn_more caption=2. What if i run it in the usual way?] It will print Insufficient number of
arguments because no arguments were passed.[/learn_more]

#10: Print its own source code using File

This is a very interesting program. Well print the source file (programName.c) without taking any
input from the user. Well be using command line arguments. As we know the first argument is the
file name well be using this concept to make programName.c by adding .c to the file name. Then
we will open the file in read mode and print the characters from the file. The source code is given
below:
?

01
02
03

#include
#include
int main(int argc,char *argv[])

04
05

{
FILE *fp;

06

argv[0]=strcat(argv[0],".c"); //to add .c to the name of the file

07

fp=fopen(argv[0],"r"); //opens the file in read mode

08

char ch;

09

while(!feof(fp)) //till it reaches the end of file

10

11
12
13

fscanf(fp,"%c",&ch);
printf("%c",ch);
}//end while
getch();

14
15

return 0;
}//end main

16
Follow up Questions:
[learn_more caption=1. What are the modes used in fopen?] There are 6 modes:

Open a file for reading. The file must exist.

w Create an empty file for writing. If a file with the same name already exists its content is
erased and the file is treated as a new empty file.

a Append to a file. Writing operations append data at the end of the file. The file is created if it
does not exist.

r+ Open a file for update both reading and writing. The file must exist.

w+ Create an empty file for both reading and writing. If a file with the same name already exists

its content is erased and the file is treated as a new empty file.

a+ Open a file for reading and appending.

INTERVIEW Q

What does static variable mean?


What is a pointer?
What is a structure?
What are
arrays?

the

In header
defined?

files

What
are
calloc()?

the

differences
whether

between

functions

differences

structures
are

between

declared
malloc()

and
or
and

What are macros?


What are its advantages and disadvantages?
Difference
value?

between

pass

by

reference

and

pass

by

What is static identifier?


Where is 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 advantages 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
referring the same element a[i][j][k][l]?

for

What is difference between Structure and Unions?


What the advantages of using Unions?
What are
program?

the

advantages

of

using

pointers

in

declared

or

What is the difference between Strings and Arrays?


In a header
defined?

file

whether

functions

are

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' means 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
declaration?

use

of

bit

fields

in

Structure

To which numbering system can the binary


1101100100111100 be easily converted to?
Which bit wise operator is suitable
whether a particular bit is on or off?

for

number
checking

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
whether a particular bit is on or off?

for

checking

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
Fibonacci
Series
Write
a
program
which
employs
Recursion Write a program which uses Command Line
Arguments Write a program which uses functions like
strcmp(), strcpy()?
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
allocated array?

the

size

of

dynamically

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
allocated by calloc()?

be

used

to

free

the

memory

How much maximum can you allocate in a single call to


malloc()?
Can you
memory?

dynamically

allocate

arrays

in

expanded

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
arguments that have been passed to it?

the

number

of

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
memmove()?

use the

functions memcpy(),

How would you use the


fwrite() and ftell()?

functions

fseek(),

memset(),
freed(),

How would you obtain the current time and difference


between two times?
How would
random()?

you

use

the

functions

randomize()

How would you implement a substr() function


extracts a sub string from a given string?

and
that

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


output on the screen?

fprintf()

to

display

the

C++ QUESTIONS Go Up 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, and 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
friendly?

mean

by

public,

private,

protected

and

When an object created and what is is its lifetime?


What do you mean by multiple inheritance and multilevel
inheritance?

Differentiate
between
realloc() and free?

them.

Difference

between

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 inheritances?
What are the advantages of inheritance?
When is a memory allocated to a class?
What
is
the
definition?

difference

between

declaration

and

What is virtual constructors/destructors?


In
c++
there
is
constructors. Why?

only

What is late
function call?

function

bound

virtual
call

destructor,
and

early

no

bound

Differentiate. How is exception handling carried out in


c++?

When will a constructor executed?


What is Dynamic Polymorphism?
Write a macro for swapping integers. DATA
QUESTIONS Go Up What is a data structure?

STRUCTURE

What does abstract data type means?


Evaluate the following prefix expression " ++ 26 + 1324" (Similar types can be asked) Convert the
following infix expression to post fix notation
((a+2)*(b+4)) -1 (Similar types can be asked) How is it
possible to insert different type of elements in
stack?
Stack can be described as a pointer. Explain. Write a
Binary Search program Write programs for Bubble Sort,
Quick sort Explain about the types of linked lists How
would you sort a linked list?
Write the programs for Linked List (Insertion and
Deletion) operations what data structure would you
mostly likely see in a non recursive implementation of
a recursive algorithm?
What do you mean by Base case, Recursive case, Binding
Time, Run-Time Stack and Tail Recursion?
Explain quick sort and merge sort algorithms and derive
the time-constraint relation for these. Explain binary
searching, Fibonacci search. What is the maximum total
number of nodes in a tree that has N levels?
Note that the root is level (zero)
How many different binary trees and binary search trees
can be made from three nodes that contain the key
values 1, 2 & 3?

A list is ordered from smaller to largest when a sort


is called. Which sort would take the longest time to
execute?
A list is ordered from smaller to largest when a sort
is called. Which sort would take the shortest time to
execute?
When will you sort an array of pointers to list
elements, rather than sorting the elements themselves?
The element being searched for is not found in an array
of 100 elements. What is the average number of
comparisons needed in a sequential search to determine
that the element is not there, if the elements are
completely unordered?
What is the average number of comparisons needed in a
sequential search to determine the position of an
element in an array of 100 elements, if the elements
are ordered from largest to smallest?
Which sort show the best average behavior?
What is the average
sequential search?

number

of

Which data structure is needed


notations to post fix notations?

comparisons

in

to

infix

convert

What do you mean by: Syntax Error Logical Error Runtime


Error How can you correct these errors?
In which data structure, elements can be
removed at either end, but not in the middle?

added

or

How will in order, preorder and post order traversals


print the elements of a tree?
Parenthesis are never
expressions. Why?

needed

in

prefix

or

postfix

Which one is faster?


A binary search of an ordered set of elements in an
array or a sequential search of the elements. JAVA
QUESTIONS Go Up What is the difference between an
Abstract class and Interface?
What is user defined exception?
What do you know about the garbage collector?
What is the difference between java and c++?
In an HTML form I have a button which makes us to open
another page in 15 seconds. How will you do that?
What is the difference between process and threads?
What is update method called?
Have you ever used Hash Table and Directory?
What are statements in Java?
What is a JAR file?
What is JNI?
What is the base class for all swing components?
What is JFC?
What is the difference between AWT and Swing?
Considering notepad/IE or any other thing as process,
What will happen if you start notepad or IE 3 times?
Where three processes is started or three threads are
started?
How does thread synchronization occur in a monitor?

Is there any tag in HTML to upload and download files?


Why do you canvas?
How
can
you
information?

know

about

drivers

and

database

What is serialization?
Can you load the server object dynamically?
If so what are the 3 major steps involved in it?
What is the layout for toolbar?
What is the difference between Grid and Gridbaglayout?
How will you add panel to a frame?
Where is the card layouts used?
What is the corresponding layout for card in swing?
What is light weight component?
Can you run the product development on all operating
systems? What are the benefits if Swing over AWT? How
can two threads be made to communicate with each
other?
What are the files generated after using IDL to java
compiler?
What is the protocol used by server and client?
What are the functionability stubs and skeletons?
What is the mapping mechanism used by java to identify
IDL language?
What is serializable interface?
What is the use of interface?

Why java is not fully objective oriented?


Why does java not support multiple inheritances?
What is the root class for all java classes?
What is polymorphism?
Suppose if we have a variable 'I' in run method, if I
can create one or more thread each thread will occupy a
separate copy or same variable will be shared?
What are virtual functions?
Write down how will you create a Binary tree?
What are the traverses in binary tree?
Write a program for recursive traverse?
What are session variable in Servlet?
What is client server computing? What is constructor
and virtual function?
Can we call a virtual function in a constructor?
Why do we use oops concepts?
What is its advantage?
What is middleware?
What is the functionality of web server?
Why is java not 100% pure oops? When will you use an
interface and abstract class?
What is the exact difference in between Unicast and
Multicast object?

Where will it be used? What is the main functionality


of the remote reference layer?
How do you download stubs from Remote place?
I want to
server?

store

more

than

10

objects

in

remote

Which methodology will follow?


What is the main functionality of Prepared Statement?
What is meant by Static query and Dynamic query?
What are Normalization Rules?
Define Normalization?
What is meant by Servlet?
What are the parameters of service method?
What is meant by Session?
Explain something about HTTP Session Class?
In a container there are 5 components. I want to
display all the component names, how will you do that?
Why there are some null interfaces in JAVA?
What does it mean?
Give some null interface in JAVA?
Tell some latest versions in JAVA related areas?
What is meant by class loader?
How many types are there?
When will we use them?

What is meant by flickering?


What is meant by distributed application?
Why are we using that in our application?
What is the functionality of the stub?
Explain about version control? Explain 2-tier and 3tier architecture?
What is the role of Web Server? How
validation of the fields in a project?

can

we

do

What is meant by cookies? Explain the main features?


Why java is considered as platform independent?
What are the advantages of java over C++?
How java can be connected to a database?
What is thread? What is difference between Process and
Thread?
Does java support multiple inheritances? If not, what
is the solution?
What are abstract classes?
What is an interface?
What is the difference abstract class and interface?
What are adapter classes?
What is meant wrapper classes?
What are JVM.JRE, J2EE, and JNI?
What are swing components?

What do you mean by light weight and heavy weight


components? What is meant by function overloading and
function overriding?
Does java support function overloading,
structures, unions or linked lists?

pointers,

What do
codes?

are

you

mean

by

multithreading?

What

byte

What are streams?


What is user defined exception?
In an HTML page form I have one button which makes us
to open a new page in 15 seconds. How will you do
that?
Advanced JAVA questions Go Up What is RMI?
Explain about RMI Architecture?
What are Servlet?
What is the use of Servlet?
Explain RMI Architecture?
How will you pass values from HTML page to the Servlet?
How do you load an image in a Servlet?
What is purpose of applet programming?
How will you communicate between two applets?
What IS the difference between Servlet and Applets?
How
do
you
Servlets?

communicate

in

between

Applets

and

What is the difference between applet and application?

What is the difference between CGI and Servlet?


In the Servlet, we are having a web page
invoking servlets, username and password?

that

is

Which is a check in database?


Suppose the second page also if we want to verify the
same information whether it will connect to the
database or it will be used previous information?
What are the difference between RMI and Servlet?
How will
Function?

you

call

an

Applet

using

Java

Script

How can you push data from an Applet to a Servlet?


What are 4 drivers available in JDBC?
At what situation are four of the drivers used?
If you are truncated using JDBC, how can you that how
much data is truncated?
How will you perform truncation using JDBC?
What is the latest version of JDBC?
What are the new features added in that?
What is
Agent?

the

difference

between

RMI

registry

and

OS

To a server method, the client wants to send a value


20, with this value exceeds to 20 a message should be
sent to the client. What will you do for achieving
this? How do you invoke a Servlet?
What is the difference between doPost method and doGet
method?

What is difference between the HTTP Servlet and Generic


Servlet?
Explain about their methods and parameters?
Can we use threads in Servlet?
Write a program
Procedure?

on

RMI

and

JDBC

using

Stored

How do you swing an applet?


How will you pass parameters in RMI?
Why do you serialize?
In RMI, server object is first loaded into memory and
then the stub reference is sent to the client. True or
false?
Suppose server object not loaded into the memory and
the client request for it. What will happen?
What is the web server used for running the servelets?
What is Servlet API used for connecting database?
What is bean?
Where can it be used?
What is the difference between java class and bean?
Can we send objects using Sockets?
What is the RMI and Socket?
What is CORBA?
Can you modify an object in corba?
What is RMI and what are the services in RMI?

What are the difference between RMI and CORBA?


How will you initialize an Applet?
What is the order of method invocation in an Applet?
What are ODBC and JDBC?
How do you connect the Database?
What do you mean by Socket Programming?
What is difference
Servlet?

between Generic

Servlet and

HTTP

What you mean by COM and DCOM?


What is e-commerce?
Operating System Questions go up what are the basic
functions of an operating system?
Explain briefly about, processor, assembler, compiler,
loader, linker and the functions executed by them. What
are the difference phases of software development?
Explain briefly?
Differentiate between RAM and ROM?
What is DRAM?
In which form does it store data?
What is cache memory?
What is hard disk and what is its purpose?
Differentiate between Complier and Interpreter?
What are the different tasks of Lexical analysis?

What are the


Scheduler?

different

functions

of

Syntax

phase,

What are the main difference between Micro-Controller


and Micro- Processor?
Describe different job scheduling in operating systems.
What is a Real-Time System?
What is the difference between Hard and Soft real-time
systems?
What is a mission critical system?
What is the important aspect of a real-time system?
If two processes which shares same system memory and
system clock in a distributed system, what is it
called?
What is the state of the processor, when a process is
waiting for some event to occur?
What do you mean by deadlock?
Explain the difference between microkernel and macro
kernel. Give an example of microkernel. When would you
choose bottom up methodology?
When would you choose top down methodology?
Write a small dc shell script to find number of FF in
the design. Why paging is used?
Which is the best page replacement algorithm and Why?
How much time is spent usually in each phases and why?
What
is
difference
secondary storage?

between

Primary

storage

and

What is multi
threading?

tasking,

multi

programming,

multi

What is difference between multi threading and multi


tasking?
What is software life cycle?
Demand paging, page faults, replacement algorithms,
thrashing, etc. Explain about paged segmentation and
segment paging while running DOS on a PC, which command
would be used to duplicate the entire diskette?
MICROPROCESSOR
QUESTIONS
architecture 8085 has?

Go

Up

which

How many memory locations can be


microprocessor with 14 address lines?

type

addressed

by

of
a

8085 is how many bit microprocessors?


Why is data bus bi-directional?
What is the function of accumulator?
What is flag, bus?
What are tri-state devices and why they are essential
in a bus oriented system?
Why are program
registers?

counter

and

stack

pointer

What does it mean by embedded system?


What are the different addressing modes in 8085?
What is the difference between MOV and MVI?
What are the functions of RIM, SIM, IN?
What is the immediate addressing mode?

16-bit

What are the different flags in 8085?


What happens during DMA transfer?
What do you mean by wait state?
What is its need? What is PSW? What is ALE?
Explain the functions of ALE in 8085. What is a program
counter? What is its use?
What is an interrupt? Which line will be activated when
an output device require attention from CPU?
ELECTRONICS QUESTIONS Go Up What is meant by D-FF?
What is the basic difference between Latches and Flip
flops? What is a multiplexer?
How can you convert an SR Flip-flop to a JK Flip-flop?
How can you convert a JK Flip-flop to a D Flip-flop?
What is Race-around problem? How can you rectify it?
Which semiconductor
regulator and why?

device

is

used

as

voltage

What do you mean by an ideal voltage source? What do


you mean by zener breakdown and avalanche breakdown?
What are the different types of filters? What is the
need of filtering ideal response of filters and actual
response of filters?
What is sampling theorem? What is impulse response?
Explain the advantages and disadvantages of FIR filters
compared to IIR counterparts. What is CMRR?
Explain briefly. What do you mean by half-duplex and
full-duplex
communication?
Explain
briefly.
Which

ranges
of
signals
transmission?

are

used

What is the need for modulation?


modulation is used in TV transmission?

for

terrestrial

Which

type

of

Why we use vestigial side band (VSB-C3F) transmission


for picture?
When transmitting digital signals is it necessary to
transmit some harmonics in addition to fundamental
frequency?
For asynchronous transmission, is it necessary
supply some synchronizing pulses additionally or
supply or to supply start and stop bit?

to
to

BPFSK is more efficient than BFSK in presence of noise.


Why?
What is meant by pre-emphasis and de-emphasis? What do
you mean by 3 dB cutoff frequency?
Why is it 3 dB, not 1 dB? What do you mean by ASCII,
EBCDIC?

Potrebbero piacerti anche