Fundamentals of Programming MCQs (Part-12)

Which of the following is considered a best practice for writing clean code in programming?

A Complex functions
B Single-purpose functions
C Using global variables
D Long variable names

What is the main goal of algorithm design in programming?

A Finding an efficient solution
B Writing long code
C Maximizing code complexity
D Minimizing memory usage

Which of the following is a common technique used to prevent security vulnerabilities in coding?

A Hardcoding passwords
B Ignoring exceptions
C Using global variables
D Input validation

Which of the following is a key principle of secure coding?

A Ignoring boundary conditions
B Using hardcoded credentials
C Proper input validation
D Error handling without logging

In Java, which method is used to sort an array of integers?

A Array.sort()
B Arrays.sort()
C List.sort()
D sort()

Which of these is considered a good practice for writing efficient algorithms?

A Using recursion excessively
B Minimizing function calls
C Avoiding loops
D Ensuring algorithms are too complex

What does the term “Big O notation” describe in algorithm design?

A Code style
B Memory usage
C Functionality of the code
D Time and space complexity

In Python, which method is used to catch an exception?

A throw()
B assert
C try-except
D handle()

What is the main benefit of using version control systems like Git in programming?

A Enhancing code readability
B Tracking code changes
C Writing comments
D Debugging code

Which of the following is a feature of Object-Oriented Programming (OOP)?

A Functions outside classes
B Global variables
C Encapsulation
D Procedural execution

What is the main purpose of debugging in software development?

A Documenting the code
B Identifying and fixing errors
C Writing code
D Compiling code

In Java, which keyword is used to inherit properties from a parent class?

A inherit
B extend
C super
D extends

Which of the following is a benefit of using recursion in algorithm design?

A Simplifies code
B Eliminates the need for loops
C Increases code complexity
D Reduces memory usage

What is the primary purpose of a constructor in Object-Oriented Programming?

A Initialize objects
B Define class properties
C Handle exceptions
D Implement inheritance

What is the main reason for following secure coding practices in programming?

A Minimize risk of security vulnerabilities
B Easier code maintenance
C Simpler code design
D Faster code execution