Multiple choice technology programming languages

Considereing int take 2 bytes of memory. What is size of memory allocated for ob in the below program.the size of memory allocated for object of class class my_class { int x; int y; public: void add(int k); void display(); }; my_class ob;

  1. 4 bytes

  2. 6 bytes

  3. 8 bytes

  4. 12 bytes

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The class my_class contains two int data members (x and y). Given that int occupies 2 bytes, the total size is 2 + 2 = 4 bytes. Member functions (add, display) do not contribute to object size as they are stored once in the code segment, not per object instance. Options B, C, and D incorrectly add extra bytes for member functions or padding.