✏️ Explanatory Question

[Primitive Values, Wrapper Classes, Types and Casting]

How many bytes of data is passed when public void stu_data(int, double, char) is invoked?

👁 0 Views
📘 Detailed Answer
🟢 Easy
💡

Answer with Explanation

Total Bytes Passed = 14 bytes

Step-by-Step Calculation:

The method contains three parameters:

int, double, char

Size of Each Data Type in Java:

Data Type Size
int 4 bytes
double 8 bytes
char 2 bytes

Total Calculation:

int → 4 bytes double → 8 bytes char → 2 bytes ----------------- Total = 4 + 8 + 2 = 14 bytes

Important Concept:

When a method is invoked, memory is allocated for parameters based on their data type sizes.

  • Primitive types occupy fixed memory size
  • Each parameter contributes to total memory passed

Key Point for Exams:

int = 4 bytes double = 8 bytes char = 2 bytes

Conclusion:

Therefore, when the method stu_data(int, double, char) is called:

Total memory passed = 14 bytes