Technical Interview & Aptitude Questions – Set 4

Technical Interview & Aptitude Questions – Set 4

Technical Interview & Aptitude Questions – Set 4

Introduction

Preparing for technical interviews requires a solid understanding of fundamental programming concepts. This guide covers commonly asked technical questions, providing clear explanations and insights to help you ace your next interview.


1. What is wrong with this statement?

scanf(%d, whatnumber);

Answer:

An ampersand (&) must be placed before the variable name whatnumber. Using & ensures that the entered integer value is stored at the memory address of the variable. Omitting & is a common mistake, leading to logical errors.


2. What does the format %10.2f mean in a printf statement?

Answer:

This format specifies field width and decimal precision:

  • 10 reserves 10 spaces for the number.
  • .2 ensures 2 decimal places.
  • If the number takes fewer than 10 spaces, it will be right-aligned with extra spaces.

3. What is a linked list?

Answer:

A linked list is a dynamic data structure consisting of nodes connected via pointers. Unlike arrays, linked lists provide efficient memory utilization.


4. What is a binary tree?

Answer:

A binary tree is a hierarchical structure where each node has at most two children, referred to as the left and right child. It is widely used in searching and sorting algorithms.


5. Differences between C and Java

Answer:

  1. C is procedural; Java is object-oriented.
  2. C is compiled; Java is interpreted.
  3. C is a low-level language; Java is high-level.
  4. C follows a top-down approach; Java follows a bottom-up approach.
  5. Java abstracts pointer usage, whereas C requires explicit pointer handling.

6. Are functions declared or defined in header files?

Answer:

Header files contain function declarations (prototypes), not their definitions. The function implementations exist in separate library files.


7. What are the different storage classes in C?

Answer:

There are four storage classes in C:

  • Extern
  • Register
  • Auto
  • Static

8. What is a static variable?

Answer:

A static variable maintains its value across multiple function calls. If declared inside a function, its scope is limited to that function but persists for the program’s lifetime.


9. How do you print a memory address in C?

Use %p in printf to display memory addresses:

Answer:

printf("Address: %p", &variable);

10. What are macros? What are their advantages and disadvantages?

Answer:

Macros are preprocessor directives that replace code at compile-time.

Advantages:

  • Faster execution as they avoid function call overhead.
  • Useful for defining constants and inline code replacements.

Disadvantages:

  • Debugging can be difficult as macros do not follow function rules.
  • Increased code size due to inline replacement.

Conclusion

Mastering these fundamental technical questions will boost your confidence in coding interviews. Practice these concepts with real-world coding problems to solidify your understanding.

Technical Interview & Aptitude Questions – Set 4"