Q.1 Why are coding standards important in software engineering?
They improve code readability
They increase program size
They make code slower
They restrict creativity
Explanation - Coding standards ensure consistent formatting and style, making code easier to read, maintain, and debug.
Correct answer is: They improve code readability
Q.2 Which of the following is a common naming convention for variables in many coding standards?
snake_case
UPPERCASE
lowerUPPER
Mixed.Case
Explanation - snake_case (e.g., user_name) is commonly used in languages like Python for readability.
Correct answer is: snake_case
Q.3 What is the main benefit of writing modular code?
Faster execution
Code reuse and maintainability
Smaller file size
Hiding bugs
Explanation - Modular code allows developers to reuse components and maintain them separately, improving productivity.
Correct answer is: Code reuse and maintainability
Q.4 Why should comments be used in code?
To explain logic
To replace code
To increase file size
To confuse others
Explanation - Comments clarify the purpose of code sections, aiding understanding for future developers.
Correct answer is: To explain logic
Q.5 Which practice should be avoided in variable naming?
Using descriptive names
Using single letters without context
Following naming conventions
Consistency
Explanation - Single-letter variable names without context reduce readability and maintainability.
Correct answer is: Using single letters without context
Q.6 What does DRY stand for in software engineering?
Don’t Repeat Yourself
Do Repeat Yourself
Dynamic Runtime Yield
Data Representation YAML
Explanation - DRY emphasizes avoiding code duplication, promoting reuse and maintainability.
Correct answer is: Don’t Repeat Yourself
Q.7 Which of these is a best practice in indentation?
Indent consistently
Indent randomly
Use no indentation
Mix spaces and tabs arbitrarily
Explanation - Consistent indentation enhances readability and prevents syntax errors in languages like Python.
Correct answer is: Indent consistently
Q.8 Why should functions be small and focused?
Easier to test and maintain
To increase execution time
To hide complexity
To confuse other developers
Explanation - Small functions with a single responsibility are easier to debug, test, and reuse.
Correct answer is: Easier to test and maintain
Q.9 Which naming style is often used for constants in many languages?
camelCase
PascalCase
UPPER_CASE
snake_case
Explanation - Constants are usually written in uppercase with underscores for clarity (e.g., MAX_SIZE).
Correct answer is: UPPER_CASE
Q.10 What is the purpose of version control in coding practices?
Track code changes
Reduce file size
Speed up execution
Obfuscate code
Explanation - Version control systems like Git track modifications, enabling collaboration and rollback.
Correct answer is: Track code changes
Q.11 Which of these is a good practice in code reviews?
Criticize developers personally
Focus on coding standards
Ignore coding style
Approve everything blindly
Explanation - Code reviews should ensure adherence to coding standards, improving quality and consistency.
Correct answer is: Focus on coding standards
Q.12 Why is meaningful naming of functions important?
It clarifies function purpose
It reduces execution time
It makes code shorter
It hides implementation
Explanation - Meaningful names describe functionality, improving readability and maintainability.
Correct answer is: It clarifies function purpose
Q.13 What should be avoided in comments?
Explaining purpose
Describing complex logic
Repeating obvious code
Documenting assumptions
Explanation - Comments should not state the obvious; they should clarify non-trivial logic.
Correct answer is: Repeating obvious code
Q.14 Which practice helps prevent code duplication?
Copy-pasting
Refactoring
Ignoring standards
Using random code
Explanation - Refactoring restructures code to reduce duplication and improve clarity.
Correct answer is: Refactoring
Q.15 Which of the following is considered a good coding practice?
Consistent formatting
Random naming
Long unbroken code blocks
Avoiding documentation
Explanation - Consistent formatting ensures readability and helps avoid misunderstandings.
Correct answer is: Consistent formatting
Q.16 Why should magic numbers be avoided in code?
They increase readability
They confuse meaning
They speed up execution
They simplify constants
Explanation - Magic numbers obscure intent; named constants clarify purpose.
Correct answer is: They confuse meaning
Q.17 What is the advantage of consistent error handling?
Better debugging and reliability
Smaller code size
Faster compilation
More code duplication
Explanation - Consistent error handling makes debugging easier and systems more robust.
Correct answer is: Better debugging and reliability
Q.18 Which is a recommended line length in many coding standards?
80–100 characters
200 characters
500 characters
Unlimited length
Explanation - Limiting line length improves readability across different devices and editors.
Correct answer is: 80–100 characters
Q.19 Why is consistent use of braces recommended?
Avoid logical errors
Increase program speed
Make code longer
Confuse developers
Explanation - Consistent brace usage reduces ambiguity and prevents mistakes in block execution.
Correct answer is: Avoid logical errors
Q.20 What is the benefit of using linters in coding?
Automatic error detection
Increase runtime speed
Obfuscate code
Remove documentation
Explanation - Linters analyze code for stylistic and structural errors, enforcing standards.
Correct answer is: Automatic error detection
Q.21 Which of these improves team collaboration?
Consistent coding standards
Personal coding style only
Ignoring conventions
Skipping documentation
Explanation - Team members working with consistent standards find it easier to understand each other’s code.
Correct answer is: Consistent coding standards
Q.22 Why should dead code be removed?
It reduces readability
It speeds up execution
It increases comments
It adds functionality
Explanation - Dead code clutters projects, making maintenance harder and confusing developers.
Correct answer is: It reduces readability
Q.23 Which is NOT a best practice in coding?
Testing regularly
Writing self-explanatory code
Hardcoding values
Using version control
Explanation - Hardcoding values reduces flexibility and makes code harder to maintain.
Correct answer is: Hardcoding values
Q.24 What is the advantage of following industry coding standards?
Improved maintainability
Unique coding style
Hidden logic
Less readability
Explanation - Industry standards ensure code is maintainable, understandable, and scalable.
Correct answer is: Improved maintainability
Q.25 Why is whitespace important in coding?
It improves readability
It increases execution speed
It makes code longer
It reduces indentation
Explanation - Whitespace organizes code visually, enhancing readability and clarity.
Correct answer is: It improves readability
