Primitive datatypes are allocated on a stack.

  1. True

  2. False


Correct Option: A

AI Explanation

To answer this question, we need to understand the concept of primitive data types and the stack.

Primitive data types, such as integers, floats, booleans, and characters, are basic data types provided by programming languages. They store simple values and have a fixed size.

The stack is a region of memory used for local variables and function calls. It follows a LIFO (Last-In, First-Out) principle, where the last item pushed onto the stack is the first one to be popped off.

Now, let's go through the options:

Option A) True - This option is correct. Primitive data types are typically allocated on the stack. When a primitive variable is declared and assigned a value, it is stored on the stack. The memory allocated for the variable is freed when it goes out of scope or when the function it is defined in returns.

Option B) False - This option is incorrect. Primitive data types are not allocated on the heap, but rather on the stack.

The correct answer is Option A) True. Primitive data types are allocated on the stack.

Find more quizzes: