Tuesday, October 9, 2007

C Interview Questions

Comment lines are
a compiled in the object code
b ignored by the compiler
c included in the executable code
d ignored by the linker.

A syntax error is signalled by the
a compiler
b linker
c editor
d run time system.

Typically a variable defined in a function/procedure/module has
a scope for the whole file
b global scope
c local scope
d retains its value between calls.

A program construct used for selection is
a if…else

b for loop
c while loop
d a sequence.

What is the result of the following expression?
6+12*3-4/2
a 22
b 25
c 40
d 52

What is the result of the following expression?
5+((2*(9+5))-4)/2
a 12.5
b 14.5
c 15
d 17

A run-time error is ALWAYS caused by
a division by zero

b incorrect logic
c error in syntax
d incorrect linkage

When a program is running the value of a constant
a can be changed
b cannot be used
c is always hidden
d cannot be changed.

The type of a function/procedure/module is determined by
a its arguments
b the value returned
c its name
d the address returned.

Which type of code is editable?
a object
b executable
c library
d source.

Test results are proved by a comparison of
a logical to syntax errors
b expected to actual input
c expected to actual output
d run time to logical errors

An argument passed by reference passes
a a global variable
b a constant
c a value
d an address

Every call to a function is checked by the compiler against the
a parameter list
b variable description
c function prototype
d program prototype

The function atoi() returns the type
a char
b float
c integer
d double

How many characters can a string hold when declared as follows?
char name[20];
a 18
b 19
c 20
d 21

Directives are translated by the
a pre-processor
b compiler
c linker
d editor

How many bytes does “D” use?
a 0.
b 1.
c 2.
d 3.

A standalone executable file requires
a no run time system
b a run time system
c a development environment
d compilation.

The switch construct is used for
a sequence
b selection
c iteration
d flags.

How many times will the following loop execute?
for(j=1; j<=10; j=j-1);

a 1.
b 10.
c Never.
d Forever.

Which one of the following is a loop construct that will always be executed once?
a for
b switch
c while
d do…while

What result is in the variable num after execution of the following statements?
int num = 58;
num % = 11;
a 3
b 5
c 8
d 11

What is the result after execution of the following code if a is 10, b is 5 and c is 10?
if((a>b) && (a<=c))
a = a + 1;
else
c = c + 1;

a a = 10, c = 10
b a = 11, c = 10
c a = 10, c = 11
d a = 11, c = 11

What is the return type of the following function prototype?
float calc(int, float, char, char);
a int
b char
c float
d void

What is the maximum number of characters that can be held in the string variable char
AddressLine[40];
a 38
b 39
c 40
d 41

What result is in the variable num1 after execution of the following statements?
int j = 1, num1 = 4;

while (++j <= 10)
{
num1++;
}
a 11
b 12
c 13
d 14

What is the result in the variable len after execution of the following statements?
int len;
char str1[ ] = {“39 March Road”};
len=strlen(str1);
a 11
b 12
c 13
d 14

What is the result in the variable str3 after execution of the following statements?
char str2[] = {“Books”};
char str3[20] = {“Fair”};
strcat(str3,str2);
a “Books Fair”
b “BooksFair”
c “Fair Books”
d “FairBooks”

Each instance of a class has a different set of
a class interfaces
b methods
c return types

d attribute values.

Methods in a class define the
a operations to be performed

b actions to be performed by its attributes
c actions to be performed on another class’s objects
d operations to be performed on another class’s attributes.

How many instances of a class can be declared?
a None.
b One.
c Ten.

d As many as required.

Typically a class is made up of
a attributes only
b methods only

c attributes and methods
d interfaces

A method declared as private can be accessed by
a its class methods only

b superclasses only
c subclass methods only
d all classes.

A constructor for a class MUST have
a no parameters
b a different na me to the class

c the same name as the class
d a return value.

One method will overload another method if they have
a different names but the same parameters
b different names with no parameters
c the same name with no parameters
d the same name but different parameters

No comments: