Programming Languages (C/C++, Python, etc.) MCQs

1. Which of the following is a valid identifier in C/C++?

A) 123identifier
B) _identifier
C) identifier-123
D) #identifier
Answer: B

2. What is the output of sizeof(‘a’) in C/C++?

A) 1
B) 2
C) 4
D) Compiler dependent
Answer: A

3. In C/C++, which keyword is used to dynamically allocate memory?

A) malloc
B) new
C) alloc
D) allocate
Answer: B

4. What does the static keyword mean when used with global variables in C/C++?

A) Limits the variable’s scope to the current function
B) Allows the variable to retain its value between function calls
C) Makes the variable read-only
D) Allocates memory on the stack
Answer: B

5. Which operator is used for pointer dereferencing in C/C++?

A) &
B) *
C) ->
D) ::
Answer: B

6. In C/C++, what does the const keyword indicate?

A) The variable cannot be modified after initialization
B) The variable must be initialized at declaration
C) The variable is declared in a constant header file
D) The variable is globally accessible
Answer: A

7. What is the result of 10 % 3 in C/C++?

A) 1
B) 2
C) 3
D) 0
Answer: A

8. Which header file should be included to use strlen() function in C/C++?

A) <math.h>
B) <stdio.h>
C) <string.h>
D) <stdlib.h>
Answer: C

9. What is the purpose of break statement in C/C++?

A) Terminates the current loop or switch statement
B) Skips the current iteration of a loop
C) Exits the program
D) Returns a value from a function
Answer: A

10. Which of the following is not a valid data type in C/C++?

A) float
B) real
C) double
D) long double
Answer: B

11. Which of the following is not a valid variable name in Python?

A) my_variable
B) 123variable
C) _my_variable
D) variable123
Answer: B

12. What is the output of 3 * 3 ** 3 in Python?

A) 81
B) 27
C) 9
D) 36
Answer: A

13. Which method is used to read a line from standard input in Python?

A) read()
B) read_line()
C) readline()
D) input()
Answer: C

14. What does the pass statement do in Python?

A) Terminates a loop
B) Executes nothing and acts as a placeholder
C) Skips the current iteration in a loop
D) Raises an exception
Answer: B

15. In Python, what is the correct way to declare a lambda function that adds two numbers?

A) lambda (a, b): a + b
B) lambda a, b: return a + b
C) lambda a, b: (a + b)
D) lambda a, b: a + b
Answer: D

16. What does the init method do in Python?

A) Initializes the class variables
B) Returns a value from a function
C) Terminates the program
D) Initializes the object’s constructor
Answer: A

17. Which of the following statements is true about Python’s list?

A) Lists are immutable
B) Lists can only store homogeneous data types
C) Lists can store heterogeneous data types
D) Lists have a fixed size
Answer: C

18. What is the output of print(“Hello” * 3) in Python?

A) Hello Hello Hello
B) HelloHelloHello
C) Hello 3
D) HelloHelloHelloHello
Answer: B

19. Which keyword is used for function definition in Python?

A) method
B) def
C) func
D) define
Answer: B

20. What does the del statement do in Python?

A) Deletes a variable or object
B) Declares a function
C) Returns a value from a function
D) Terminates a loop
Answer: A

21. Which programming language is known for its use in statistical computing and data analysis?

A) Java
B) C++
C) Python
D) Ruby
Answer: C

22. In object-oriented programming, what is inheritance?

A) Ability of a class to inherit properties and behavior from another class
B) A class that implements multiple interfaces
C) A function calling itself
D) Passing arguments by reference
Answer: A

23. What does the term “polymorphism” mean in the context of programming languages?

A) Ability of a function to call itself
B) Ability of a function to return different data types
C) Ability of objects to respond to method calls of the same name
D) Ability of a language to support multiple paradigms
Answer: C

24. Which type of programming language allows you to write algorithms in a human-readable format that can be executed directly by a computer?

A) Low-level language
B) High-level language
C) Assembly language
D) Machine language
Answer: B

25. What is the purpose of a conditional statement in programming?

A) Repeats a block of code until a condition is met
B) Executes a block of code only if a certain condition is true
C) Terminates the program
D) Declares variables and functions
Answer: B

26. Which programming paradigm emphasizes breaking down a problem into smaller, reusable parts called functions?

A) Procedural programming
B) Functional programming
C) Object-oriented programming
D) Declarative programming
Answer: A

27. What is the purpose of a loop in programming?

A) Executes a block of code repeatedly until a condition is met
B) Declares variables and functions
C) Terminates the program
D) Calls a function recursively
Answer: A

28. Which term describes the process of finding and fixing errors in a computer program?

A) Compilation
B) Debugging
C) Optimization
D) Refactoring
Answer: B

29. In programming languages, what does the term “syntax” refer to?

A) Rules that define the structure of statements in the language
B) Rules that define the behavior of objects
C) Rules that define the data types available in the language
D) Rules that define the memory allocation for variables
Answer: A

30. What does the term “algorithm” mean in programming?

A) Sequence of instructions to solve a problem
B) Programming language syntax
C) Object-oriented design pattern
D) Low-level machine instructions
Answer: A

31. What is the output of the following C/C++ code snippet?

A) 5
B) 6
C) 4
D) Compiler Error
Answer: A

32. Which statement correctly allocates memory for an array of integers in C/C++?

A) int arr[10];
B) int *arr = new int[10];
C) int arr[10] = {0};
D) int *arr = malloc(10 * sizeof(int));
Answer: B

33. What does the sizeof operator return in C/C++ for a float data type?

A) 2
B) 4
C) 8
D) Compiler dependent
Answer: B

34. What is the purpose of the extern keyword in C/C++?

A) Specifies that a variable or function is defined elsewhere
B) Declares a constant variable
C) Allocates memory on the heap
D) Initializes a static variable
Answer: A

35. In C/C++, what is the output of printf(“%d”, sizeof(char))?

A) 1
B) 2
C) 4
D) Compiler dependent
Answer: A

36. What is the output of the following Python code?

A) [1] [2]
B) [1] [1, 2]
C) [1] [2, 2]
D) [1] [1, 2, 2]
Answer: D

37. Which of the following Python statements is used to exit a loop prematurely?

A) break
B) continue
C) pass
D) exit
Answer: A

38. What does the with statement do in Python?

A) Closes files and releases resources automatically after use
B) Executes a block of code repeatedly
C) Skips the current iteration in a loop
D) Returns a value from a function
Answer: A

39. In Python, what is the result of 2 ** 3 ** 2?

A) 8
B) 64
C) 512
D) 9
Answer: B

40. What is the purpose of the is keyword in Python?

A) Checks if two variables refer to the same object
B) Checks if two variables have the same value
C) Compares two strings lexicographically
D) Performs bitwise comparison
Answer: A

41. Which programming language is known for its use in web development and server-side scripting?

A) Java
B) PHP
C) C#
D) Swift
Answer: B

42. What is the main advantage of using pointers in C/C++?

A) Allows direct access to hardware resources
B) Facilitates dynamic memory allocation and manipulation
C) Improves program execution speed
D) Reduces code complexity
Answer: B

43. In object-oriented programming, what is encapsulation?

A) Binding data and functions that manipulate the data into a single unit
B) Hiding the implementation details of a class from its objects
C) Restricting access to class members
D) Allowing one class to inherit from another class
Answer: A

44. What does the term “interpreter” refer to in programming languages?

A) Converts source code into machine code before execution
B) Translates high-level language code into assembly language
C) Executes instructions directly without compiling them first
D) Optimizes the performance of compiled code
Answer: C

45. Which programming language is known for its use in numerical computing, scientific computing, and data analysis?

A) Python
B) Ruby
C) JavaScript
D) Swift
Answer: A

46. What is the purpose of the lambda keyword in programming languages?

A) Defines anonymous functions
B) Allocates memory dynamically
C) Specifies conditional statements
D) Declares static variables
Answer: A

47. Which type of programming language is designed to be easy for humans to read and write?

A) High-level language
B) Low-level language
C) Assembly language
D) Machine language
Answer: A

48. What is the primary function of the continue statement in programming?

A) Terminates the current loop iteration and resumes the next iteration
B) Exits the loop completely
C) Skips the current iteration without executing any further statements
D) Jumps to a specific label in the program
Answer: C

49. Which programming paradigm emphasizes defining what the program should accomplish without specifying how to achieve the result?

A) Procedural programming
B) Object-oriented programming
C) Functional programming
D) Declarative programming
Answer: D

50. What does the term “overloading” mean in programming languages?

A) Defining multiple functions with the same name but different parameters
B) Calling a function within itself
C) Replacing a function call with its definition
D) Reserving memory for variables
Answer: A

More MCQs on Avionics Engineering MCQs

  1. Artificial Intelligence MCQs
  2. Cybersecurity in Avionics MCQs
  3. Spacecraft Avionics MCQs
  4. Unmanned Aerial Vehicles (UAVs) MCQs
  5. Emerging Technologies MCQs
  6. Systems Engineering MCQs
  7. Engineering Economics MCQs
  8. Project Management MCQs
  9. Thermodynamics MCQs
  10. Electromagnetism MCQs
  11. Electromagnetism MCQ
  12. Classical Mechanics MCQs
  13. Modelling and Simulation Techniques MCQs
  14. Aircraft Simulation MCQs
  15. Fault Diagnosis and Management MCQs
  16. Reliability Engineering MCQs
  17. Aircraft Safety Systems MCQs
  18. Aerospace Materials and Composites MCQs
  19. Material Science MCQs
  20. Advanced Control Systems MCQs
  21. Avionics Integration MCQs
  22. Advanced Navigation Systems MCQs
  23. Antenna Theory and Design MCQs
  24. Satellite Communication MCQs
  25. Radio Frequency Communication MCQs
  26. Measurement and Data Acquisition MCQs
  27. Sensor Technologies MCQs
  28. Aircraft Instrumentation MCQs
  29. Communication Signal Processing MCQs
  30. Analog Signal Processing MCQs
  31. Real-Time Systems MCQs
  32. Software Engineering MCQs
  33. Programming Languages (C/C++, Python, etc.) MCQs
  34. Computer Science and Software Engineering MCQs
  35. Instrumentation and Control MCQs
  36. Flight Control Systems MCQs
  37. Control Engineering MCQs
  38. Microprocessors and Microcontrollers MCQs
  39. Electronics and Electrical Engineering MCQs
  40. Radar and Surveillance Systems MCQs
  41. Communication Systems MCQs
  42. Aircraft Navigation Systems MCQs
  43. Avionics System Design MCQs
  44. Aircraft Structures MCQs
  45. Aerodynamics MCQs
  46. Flight Mechanics MCQs
  47. Introduction to Aerospace Engineering MCQs
  48. Aerospace Fundamentals MCQs
  49. Avionics Engineering MCQs

Leave a Comment

All copyrights Reserved by MCQsAnswers.com - Powered By T4Tutorials