Explain memory allocation process in C.
- Static memory allocation: The memory allocation during the beginning of the program is known as static memory allocation. In this type of memory allocation allocated memory size remains fixed and it is not allowed to change the memory size during run-time. It will make use of a stack for memory management.
- Dynamic memory allocation: The memory allocation during run-time is considered as dynamic memory allocation. We can mention the size at runtime as per requirement. It will make use of heap data structure for memory management. The required memory space can be allocated and deallocated from heap memory. It is mainly used in pointers. Four types of the pre-defined function that are used to dynamically allocate the memory are given below:
malloc()
calloc()
realloc()
free()
What is the “Diamond problem” in Java?
The “Diamond problem” usually happens in multiple inheritances. Java does not support multiple inheritances, so in the case of Java, the diamond problem occurs when you are trying to implement multiple interfaces. When two interfaces having methods with the same signature are implemented to a single class, it creates ambiguity for the compiler about which function it has to call, so it produces an error at the compile time. Its structure looks similar to diamond thus it is called a “Diamond problem”.
Here, if we try to access the print() function using the DerivedClass3 object, it will create confusion for the compiler that which copy of the print() function it has to call i.e., from DerivedClass1 or DervivedClass2.
“Diamond problem” is solved by using virtual inheritance. It guarantees that the child class will get only one instance of the common base class.
Is Accenture a great place to start a career?
Below mentioned are some of the major reasons why Accenture is a great place to start your career: