TN Online TestSamacheer Kalvi practice

12th Standard Computer Science — Function: Additional MCQs with Answers & Explanations

Share this chapter: Telegram

15 extra multiple-choice questions for Function (12th Standard Computer Science, Samacheer Kalvi), beyond the ones printed in the textbook — each with the correct option highlighted and a clear, worked explanation. Free to read in English and Tamil.

Answer key at a glance

Q1
Which of the following is true about definitions in function specifications?
  • A. Definitions are expressions.
  • B. Expressions are treated as definitions.
  • C. Definitions are distinct syntactic blocks.Correct
  • D. Definitions cannot have nested expressions.
Explanation. In function specification, definitions are distinct syntactic blocks that bind values to names. They are not expressions, and expressions are not treated as definitions, though they can be nested inside each other.
Q2
What does the type signature x1 -> x2 -> y indicate in function types?
  • A. A function that takes one input of type x1 and returns x2 and y.
  • B. A function that takes two inputs of types x1 and x2, and returns an output of type y.Correct
  • C. A function that takes an input of type y and maps it to x1 and x2.
  • D. A recursive function with two base cases of types x1 and x2.
Explanation. The syntax x1 -> x2 -> y represents a function type that takes two inputs, the first of type x1 and the second of type x2, and produces an output of type y.
Q3
When writing explicit type annotations for parameters in a function definition, which of the following is mandatory?
  • A. Square brackets [ ]
  • B. Curly braces { }
  • C. Parentheses ( )Correct
  • D. Angle brackets < >
Explanation. As per the rules of parameter typing in the textbook, when writing explicit type annotations for parameters (such as (a: int)), the parentheses are mandatory.
Q4
Which keyword must accompany let to define a recursive function?
  • A. recur
  • B. recCorrect
  • C. repeat
  • D. loop
Explanation. In the function syntax, the keyword rec is required after let (forming let rec) if the defined function is recursive (calls itself).
Q5
Why is the function strlen considered a pure function in programming?
  • A. It modifies the string passed to it during execution.
  • B. It returns a random value each time it is called.
  • C. It only reads the external memory of the string to find its length without modifying it.Correct
  • D. It depends on global variables that change dynamically.
Explanation. strlen is a pure function because it only accesses the external memory of the string to calculate its length, but does not modify the memory or string, ensuring consistent results for the same input.
Q6
If a compiler compiles a loop containing several calls to a pure function like strlen(s) where s is not updated, what optimization can a smart compiler perform?
  • A. Convert the pure function into an impure function.
  • B. Force the loop to run indefinitely.
  • C. Remove redundant calls and execute the function only once.Correct
  • D. Ignore the function call completely.
Explanation. Since strlen is a pure function and the string s is not modified inside the loop, a smart compiler can determine that the value is constant, remove the redundant extra calls, and execute it once.
Q7
Which of the following is an example of a side effect that makes a function impure?
  • A. Returning the square of an input integer.
  • B. Calculating the greatest common divisor of two numbers.
  • C. Modifying a variable that resides outside the function's scope.Correct
  • D. Performing a mathematical sine calculation on a constant value.
Explanation. Modifying an external variable (outside the function's block) is a side effect that alters the state of the program, causing the function to behave inconsistently and making it impure.
Q8
In the Chameleons of Chromeland problem, if the initial numbers of chameleons of types A, B, and C are 4, 4, and 6 respectively, what is the final number of chameleons of the third type after all have been monochromatized?
  • A. 10
  • B. 12
  • C. 14Correct
  • D. 8
Explanation. Initially, there are 4 + 4 + 6 = 14 chameleons. In the end, all chameleons display the same color of the third type, so the final count is the sum of all chameleons, which is 14.
Q9
Which of the following statements is true regarding function definitions in the context of the textbook?
  • A. Functions can be defined both statically and dynamically.
  • B. All functions are static definitions, and there are no dynamic function definitions.Correct
  • C. Recursive functions are always dynamic definitions.
  • D. Functions can only be defined inside other functions dynamically.
Explanation. According to the textbook notes, all function definitions are static, and there are no dynamic function definitions.
Q10
In Object-Oriented Programming, how do we refer to the template that specifies the interfaces to enable an object to be created and operated?
  • A. Subroutine template
  • B. Class templateCorrect
  • C. Syntactic block
  • D. Parameter specification
Explanation. The class template specifies the interfaces that enable an object to be created and operated properly, acting as a blueprint or cookie cutter.
Q11
In the recursive definition of the greatest common divisor: let rec gcd a b := if b <> 0 then gcd b (a mod b) else return a, which statement or part handles the termination of the recursion?
  • A. let rec gcd a b
  • B. then gcd b (a mod b)
  • C. if b <> 0
  • D. else return aCorrect
Explanation. The recursion terminates and returns the result a when the condition b <> 0 becomes false (i.e., b becomes 0). This is executed in the else return a branch.
Q12
What does the term "wishful thinking" refer to in the strategy of designing programs?
  • A. Delaying the coding of the entire program until the final exam.
  • B. Assuming the existence of constructors and selectors before defining their concrete implementation.Correct
  • C. Hoping that the compiler will automatically fix syntax errors without debugging.
  • D. Expecting an impure function to behave like a pure function.
Explanation. In program design, wishful thinking is a strategy where you assume that constructors and selectors are already available to manipulate abstract data, allowing you to design the flow before implementation.
Q13
Consider the following code segment: y := 0 let inc (x: int): int := y := y + x return (y) What is the side effect of calling the inc function?
  • A. It returns an incorrect integer sum.
  • B. It requires mandatory parentheses for type annotations.
  • C. It changes the value of the externally visible variable y.Correct
  • D. It recursively calls itself until y is zero.
Explanation. The side effect of the inc function is that it modifies the value of y, which is a variable defined outside the function's block, making it an impure function.
Q14
Which of the following is true about pure and impure functions regarding their argument modification?
  • A. Pure functions modify the arguments passed to them, whereas impure functions do not.
  • B. Neither pure nor impure functions can modify arguments.
  • C. Both pure and impure functions must modify their arguments.
  • D. Pure functions do not modify their arguments, while impure functions may modify them.Correct
Explanation. One of the key differences listed in the textbook is that pure functions do not modify the arguments passed to them, whereas impure functions may modify them.
Q15
What happens when a function depends on variables or functions defined outside of its own definition block?
  • A. It is guaranteed to be a pure function.
  • B. It can never be sure to behave the same way every time it is called.Correct
  • C. It will cause a compilation error due to type inference.
  • D. It is automatically optimized by the compiler to execute once.
Explanation. When a function depends on external variables or functions, its behavior is subject to external changes, meaning you can never be sure it will behave the same every time it's called (making it impure).
Take the Additional practice test → Open the app

More for this chapter

Book Back Questions10 textbook MCQs · solved Practice TestInteractive · instant score Book Back TestTest yourself on the textbook set Additional MCQ TestTest yourself on the extra set Study NotesConcepts & methods Formula SheetAll key formulas

About these Function questions

These are the Additional multiple-choice questions for Function from the Tamil Nadu State Board (Samacheer Kalvi) 12th Standard Computer Science syllabus. Each question shows the correct option and an original, step-by-step explanation so you understand the method, not just the answer. Use the answer key above to jump to any question, then take the practice test to check yourself under exam-like conditions.

Frequently asked questions

How many MCQs are there in Function?

This chapter has 15 book-back multiple-choice questions, each with the correct answer and a step-by-step explanation.

Are these 12th Standard Computer Science MCQs free to practise online?

Yes. Every question, answer and explanation here is free, and you can also take them as a timed practice test.

Where can I find the Function book-back answers?

The correct option for each question is highlighted on this page with a worked explanation, plus a quick answer-key summary at the top.

More chapters in Computer Science

View all
2 Data Abstraction 3 Scoping 4 Algorithmic Strategies 5 Python -Variables and Operators 6 Control Structures 7 Python functions 8 Strings and String manipulation 9 Lists, Tuples, Sets and Dictionary 10 Python Classes and objects 11 Database Concepts 12 Structured Query Language (SQL) 13 Python and CSV files 14 Importing C++ programs in Python. 15 Data manipulation through SQL 16 Data visualization using pyplot: line chart, pie chart and bar chart