Computer MCQs

Programming Languages MCQs with Answers

Which of the following programming languages is primarily used for front-end web development?
A. Python
B. Java
C. HTML
D. C++
Answer: C

What does the acronym “OOP” stand for in the context of programming languages?
A. Object-Oriented Programming
B. Operator Overloading Protocol
C. Output Oriented Processing
D. Operand Object Protocol
Answer: A

In Python, what function is used to get the length of a list?
A. size()
B. length()
C. count()
D. len()
Answer: D

Which programming language is known for its use in statistical computing and data analysis?
A. Java
B. Python
C. C#
D. Ruby
Answer: B

What is the purpose of the “malloc” function in the C programming language?
A. Memory allocation
B. Mathematical calculation
C. String manipulation
D. File input/output
Answer: A

Which symbol is used to declare a pointer variable in C++?
A. *
B. &
C. #
D. $
Answer: A

In JavaScript, what is the purpose of the “querySelector” method?
A. Select an HTML element by its class
B. Select an HTML element by its ID
C. Select multiple HTML elements
D. Select the document body
Answer: B

Which programming paradigm emphasizes writing code in a declarative style?
A. Procedural programming
B. Object-Oriented Programming (OOP)
C. Functional programming
D. Imperative programming
Answer: C

What is the purpose of the “try…catch” block in languages like JavaScript?
A. Loop control
B. Exception handling
C. Variable declaration
D. Function definition
Answer: B

Which keyword is used for defining a constant in C++?
A. constant
B. define
C. const
D. final
Answer: C

In Python, what is the purpose of the “zip” function?
A. Compress files
B. Combine multiple lists into tuples
C. Unzip files
D. Create a zip archive
Answer: B

Which of the following is a dynamically typed programming language?
A. Java
B. C++
C. Python
D. C#
Answer: C

What does the acronym “SQL” stand for in the context of programming languages?
A. Structured Query Language
B. Standard Query Language
C. System Query Language
D. Sequential Query Language
Answer: A

In Java, which keyword is used to implement multiple inheritance?
A. inherit
B. extends
C. implements
D. multi
Answer: C

What is the purpose of the “git clone” command in version control systems like Git?
A. Create a new branch
B. Copy a repository from a remote server
C. Merge branches
D. Commit changes
Answer: B

Which of the following is not a valid variable name in most programming languages?
A. my_variable
B. 123_variable
C. _variable
D. variable123
Answer: B

What is the primary purpose of the “else” statement in conditional structures?
A. Execute code block if a condition is true
B. Execute code block if a condition is false
C. Break out of a loop
D. Define a constant
Answer: B

In Python, what is the purpose of the “lambda” function?
A. Create anonymous functions
B. Handle exceptions
C. Access elements in a dictionary
D. Convert data types
Answer: A

Which data structure is used to implement a Last-In-First-Out (LIFO) order in programming?
A. Queue
B. Stack
C. Linked List
D. Array
Answer: B

What is the purpose of the “super” keyword in Python?
A. Access superclass methods and properties
B. Initialize a new object
C. Define a constant
D. Implement multiple inheritance
Answer: A

In JavaScript, what is the purpose of the “innerHTML” property?
A. Retrieve the HTML content of an element
B. Change the background color of an element
C. Add a new HTML element to the document
D. Modify the document’s title
Answer: A

Which of the following is a statically typed programming language?
A. Python
B. JavaScript
C. C#
D. Ruby
Answer: C

What does the acronym “API” stand for in the context of programming?
A. Advanced Programming Interface
B. Application Programming Interface
C. Automated Programming Interface
D. Algorithmic Programming Interface
Answer: B

In Java, what is the purpose of the “toString” method?
A. Convert a string to lowercase
B. Concatenate two strings
C. Convert an object to its string representation
D. Retrieve the length of a string
Answer: C

Which of the following is an example of a compiled programming language?
A. Python
B. JavaScript
C. Java
D. PHP
Answer: C

What is the purpose of the “break” statement in loops?
A. Skip the next iteration of the loop
B. Terminate the loop and exit
C. Pause the loop temporarily
D. Resume the loop from the beginning
Answer: B

In Python, what is the purpose of the “map” function?
A. Iterate over a sequence
B. Apply a function to each element in a sequence
C. Filter elements from a sequence
D. Reverse a sequence
Answer: B

Which of the following is an example of a high-level programming language?
A. Assembly language
B. Machine language
C. C
D. Python
Answer: D

What is the purpose of the “async” keyword in languages like JavaScript?
A. Define a constant
B. Indicate that a function is asynchronous
C. Create an array
D. Implement exception handling
Answer: B

In C++, what is the purpose of the “friend” keyword?
A. Declare a function prototype
B. Indicate a class method
C. Specify a friend class with access to private members
D. Implement multiple inheritance
Answer: C

Which programming language was developed by Microsoft and is commonly used for Windows application development?
A. Python
B. Java
C. C#
D. Ruby
Answer: C

What is the purpose of the “this” keyword in object-oriented programming languages?
A. Refer to the current class
B. Refer to the current object instance
C. Define a constant
D. Create an anonymous function
Answer: B

Which of the following is a relational database management system (RDBMS)?
A. MongoDB
B. SQLite
C. Redis
D. Cassandra
Answer: B

In JavaScript, what is the purpose of the “NaN” value?
A. Not a Number
B. Null and None
C. Negative Number
D. New Assignment Needed
Answer: A

What is the purpose of the “git pull” command in version control systems like Git?
A. Push changes to a remote repository
B. Fetch changes from a remote repository and merge
C. Create a new branch
D. View commit history
Answer: B

Which of the following is a functional programming language?
A. Java
B. C++
C. Haskell
D. PHP
Answer: C

In Python, what is the purpose of the “strip” method for strings?
A. Split a string into a list
B. Remove leading and trailing whitespace
C. Concatenate two strings
D. Replace a substring in a string
Answer: B

What is the purpose of the “cout” statement in C++?
A. Input from the console
B. Output to the console
C. Concatenate two strings
D. Declare a constant
Answer: B

Which of the following is a scripting language commonly used for web development?
A. C
B. Java
C. Python
D. C#
Answer: C

In JavaScript, what is the purpose of the “event.preventDefault()” method?
A. Stop the propagation of an event
B. Prevent the default action associated with an event
C. Create a new event
D. Trigger an event manually
Answer: B

What is the purpose of the “docker run” command in containerization technology like Docker?
A. Build a Docker image
B. Run a Docker container
C. Stop a Docker container
D. Remove a Docker container
Answer: B

In Python, what is the purpose of the “enumerate” function?
A. Create a dictionary
B. Iterate over a sequence with an index
C. Sort a list
D. Convert a list to a tuple
Answer: B

Which of the following is a low-level programming language?
A. Assembly language
B. Python
C. Java
D. C#
Answer: A

What is the purpose of the “git merge” command in version control systems like Git?
A. Create a new branch
B. Merge changes from one branch into another
C. Push changes to a remote repository
D. View commit history
Answer: B

In Java, what is the purpose of the “static” keyword?
A. Define a constant
B. Indicate that a method belongs to the class, not the instance
C. Implement multiple inheritance
D. Create a new object
Answer: B

What is the purpose of the “return” statement in functions?
A. Terminate the program
B. Return a value from the function
C. Print a message to the console
D. Declare a constant
Answer: B

Which of the following is an interpreted programming language?
A. C
B. Java
C. Python
D. C#
Answer: C

In JavaScript, what is the purpose of the “addEventListener” method?
A. Modify the HTML content of an element
B. Attach an event handler to an element
C. Create a new element
D. Remove an element from the DOM
Answer: B

What is the purpose of the “continue” statement in loops?
A. Skip the next iteration of the loop
B. Terminate the loop and exit
C. Pause the loop temporarily
D. Resume the loop from the beginning
Answer: A

Which programming language is known for its use in machine learning and artificial intelligence?
A. Java
B. C++
C. Python
D. Ruby
Answer: C

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button