Important Introduction to Programming Short Questions
Chapter: 45
Question 1:
How is a matrix represented in the context of the << operator function?
Answer:
It is represented by calling the output function to write the matrix to the stream.
Chapter: 45
Question 2:
What does the >> operator function do for matrix input?
Answer:
It uses the input function to read matrix values from the stream and populate the matrix.
Chapter: 45
Question 3:
Why is memory management important in matrix class operations?
Answer:
Proper memory management ensures that memory is allocated and deallocated correctly to prevent memory leaks or access violations.
Chapter: 45
Question 4:
What is the main difference between loops and decision structures in programming?
Answer:
Loops perform repeated actions while decision structures control the flow of execution based on conditions.
Chapter: 45
Question 5:
How do pointers differ from variables in C and C++?
Answer:
Pointers hold memory addresses, while variables hold values directly. Pointers can be used to dynamically manage memory.
Chapter: 45
Question 6:
What is an array and how does it differ in various programming languages?
Answer:
An array stores multiple values of the same type. Different languages handle arrays differently; some support mixed-type elements, others do not.
Chapter: 45
Question 7:
How does the do-while loop differ from the while loop?
Answer:
A do-while loop executes its body at least once before checking its condition, while a while loop may not execute at all if its condition is false initially.
Chapter: 45
Question 8:
What is encapsulation in the context of object-oriented programming?
Answer:
Encapsulation combines data and methods into a single unit (object) and restricts direct access to some of its components, enhancing modularity.
Chapter: 45
Question 9:
How does Java's garbage collection address issues with memory management?
Answer:
Java uses garbage collection to automatically reclaim memory used by objects no longer in use, avoiding manual memory management and issues like dangling pointers.